I am working on a development , which does the following
closes all Activities in teh system ( of a vcertain process type )
creates 1 activity eack for all accounts present in the system
also map the marketing attributes per account
create a survey with the responses as the corresponsdng marketing attribute and attach the survey to the account
Now there are 16000 accounts in the system
and i have used CRM_ORDER_MAINTAIN thrice
Once while closing the Activities
Once while creating new activities without a survey ( based on certain conditions)
and once while creating activities with surveys
I am facing prformance issues, the code is taking 40000 odd hours to complete in a batch job
I have performed SE30 /SAT , sm50 ..the major time s consumed by CRM_ORDER_MAINTAIN.Could you kindly suggest a way out to improve the performance .
I pasting the portion of the code here :
call function 'CRM_ORDER_MAINTAIN'
exporting
it_activity_h = lt_activity_h
it_appointment = lt_appointment
it_partner = lt_partner
it_status = lt_status
changing
ct_orderadm_h = lt_orderadm_h
ct_input_fields = ct_input_fields2
exceptions
error_occurred = 1
document_locked = 2
no_change_allowed = 3
no_authority = 4
others = 5.
if sy-subrc eq 0.
* * build save table
loop at lt_orderadm_h into ls_orderadm_h.
ls_objects_to_save = ls_orderadm_h-guid.
append ls_objects_to_save to lt_objects_to_save.
clear:ls_orderadm_h, ls_objects_to_save.
endloop.
endif.
if lt_objects_to_save[] is not initial.
call function 'CRM_ORDER_SAVE'
exporting
it_objects_to_save = lt_objects_to_save
iv_update_task_local = 'X'
iv_save_frame_log = 'X'
importing
et_saved_objects = lt_saved_objects
* et_exception = lt_exception
* et_objects_not_saved = lt_objects_not_saved
exceptions
document_not_saved = 1
others = 2.
if sy-subrc eq 0.
clear: lt_return2.
call function 'BAPI_TRANSACTION_COMMIT' "#EC FB_NORC
exporting
wait = 'X'
importing
return = lt_return2.
call function 'CRM_ORDER_INITIALIZE'
exporting
it_guids_to_init = lt_objects_to_save
iv_initialize_whole_buffer = 'X'
iv_init_frame_log = 'X' ""true
iv_keep_lock = ' ' "false
exceptions
error_occurred = 1
others = 2.
endif.