on ‎2020 Aug 17 11:40 AM
I want to create parallel processing technique for reduce performance issue.
I am using crm_order_read FM, To get details of documents.
In below code: For large amount of data, i am splitting into small parts of data and passing into FM to get quicker data
likewise this method I need to be done in parallel processing technique. please help me with it
index2 = 1.
DO.
index1 = index2.
index2 = index1 + 5000.
APPEND LINES OF lt_header_guid FROM index1 TO index2 - 1 TO lt_header_guid_temp.
IF lt_header_guid_temp IS INITIAL.
EXIT.
ENDIF.
CALL FUNCTION 'CRM_ORDER_READ'
EXPORTING
it_header_guid = lt_header_guid_temp
it_requested_objects = lt_req_objects
IMPORTING
et_orderadm_h = lt_orderadm_h_temp
et_orderadm_i = lt_orderadm_i_temp
et_orgman = lt_orgman_temp
et_partner = lt_partner_temp
et_status = lt_status_temp
et_doc_flow = lt_doc_flow_temp
EXCEPTIONS
document_not_found = 1
error_occurred = 2
document_locked = 3
no_change_authority = 4
no_display_authority = 5
no_change_allowed = 6
OTHERS = 7.
IF sy-subrc EQ 0.
* Implement suitable error handling here
ENDIF.
INSERT LINES OF: lt_orderadm_h_temp INTO TABLE lt_orderadm_h,
lt_orderadm_i_temp INTO TABLE lt_orderadm_i,
lt_orgman_temp INTO TABLE lt_orgman,
lt_partner_temp INTO TABLE lt_partner,
lt_status_temp INTO TABLE lt_status,
lt_doc_flow_temp INTO TABLE lt_doc_flow.
REFRESH: lt_header_guid_temp,lt_orderadm_h_temp,lt_orderadm_i_temp,lt_orgman_temp,lt_partner_temp,lt_status_temp,lt_doc_flow_temp.
ENDDO.
Request clarification before answering.
For parallel processing of CRM_ORDER_READ, you would call the FM this way in order to start and receive the parallel tasks:
" 1) Start parallel task
CALL FUNCTION func " CRM_ORDER_READ
STARTING NEW TASK task " distinct task name
[DESTINATION {dest|{IN GROUP {group|DEFAULT}}}] " recommended with many app-servers
[{CALLING meth}|{PERFORMING subr} ON END OF TASK] " receive output when task is finished
parameter_list. " FM 'input' parameters
" Input Parameters contain also those parameters for changing and tables if necessary for input
" 2) Receive parallel task
RECEIVE RESULTS FROM FUNCTION func
parameter_list.This is how you would do it based on your provided coding:
FORM start_tasks.
" DO-Loop and setup of parallel tasks
index2 = 1.
DO.
REFRESH: lt_header_guid_temp,lt_orderadm_h_temp,lt_orderadm_i_temp,
lt_orgman_temp,lt_partner_temp,lt_status_temp,lt_doc_flow_temp.
index1 = index2.
index2 = index1 + 5000.
APPEND LINES OF lt_header_guid FROM index1 TO index2 - 1 TO lt_header_guid_temp.
IF lt_header_guid_temp IS INITIAL.
EXIT.
ENDIF.
" start parallel task
CALL FUNCTION 'CRM_ORDER_READ'
STARTING NEW TASK taskname " e.g. 'ORDER_READ' && DO-index
DESTINATION IN GROUP 'parallel_generators' " standard server group for parallel tasks
PERFORMING receive_tasks ON END OF TASK " form in report
EXPORTING
it_header_guid = lt_header_guid_temp
it_requested_objects = lt_req_objects
EXCEPTIONS
resource_failure = 10
system_failure = 11 MESSAGE l_msg_text
communication_failure = 12 MESSAGE l_msg_text
OTHERS = 13.
IF sy-subrc <> 0.
" error handling
ENDIF.
ENDDO.
ENDFORM.
FORM receive_tasks USING taskname.
RECEIVE RESULTS FROM FUNCTION 'CRM_ORDER_READ'
IMPORTING
et_orderadm_h = lt_orderadm_h_temp
et_orderadm_i = lt_orderadm_i_temp
et_orgman = lt_orgman_temp
et_partner = lt_partner_temp
et_status = lt_status_temp
et_doc_flow = lt_doc_flow_temp
EXCEPTIONS
document_not_found = 1
error_occurred = 2
document_locked = 3
no_change_authority = 4
no_display_authority = 5
no_change_allowed = 6
resource_failure = 10
system_failure = 11 MESSAGE l_msg_text
communication_failure = 12 MESSAGE l_msg_text
OTHERS = 13.
IF sy-subrc <> 0.
" error handling
ELSE.
INSERT LINES OF: lt_orderadm_h_temp INTO TABLE lt_orderadm_h,
lt_orderadm_i_temp INTO TABLE lt_orderadm_i,
lt_orgman_temp INTO TABLE lt_orgman,
lt_partner_temp INTO TABLE lt_partner,
lt_status_temp INTO TABLE lt_status,
lt_doc_flow_temp INTO TABLE lt_doc_flow.
ENDIF.
ENDFORM.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi michael,
Thanks for your answer, All of it working fine.
but I cannot able to receive final output from receive_tasks method.
CALL FUNCTION 'CRM_ORDER_READ'
STARTING NEW TASK lv_task
DESTINATION IN GROUP 'parallel_generators' " standard server group for parallel tasks
CALLING receive_task ON END OF TASK
EXPORTING
lt_header_guid_temp = lt_header_guid_temp
lt_req_objects = lt_req_objects
EXCEPTIONS
resource_failure = 10
system_failure = 11 MESSAGE lv_msgv1
communication_failure = 12 MESSAGE lv_msgv1
OTHERS = 13.
IF sy-subrc <> 0.
" error handling
ENDIF.METHOD receive_task.
REFRESH: lt_orderadm_h_tmp,lt_orderadm_i_tmp,lt_orgman_tmp,lt_partner_tmp,lt_status_tmp,lt_doc_flow_tmp.
RECEIVE RESULTS FROM FUNCTION 'CRM_ORDER_READ'
IMPORTING
lt_orderadm_h_temp = lt_orderadm_h_tmp
lt_orderadm_i_temp = lt_orderadm_i_tmp
lt_orgman_temp = lt_orgman_tmp
lt_partner_temp = lt_partner_tmp
lt_status_temp = lt_status_tmp
lt_doc_flow_temp = lt_doc_flow_tmp
EXCEPTIONS
resource_failure = 1
system_failure = 2 MESSAGE lv_msgv1
communication_failure = 3 MESSAGE lv_msgv1.
IF sy-subrc <> 0.
" error handling
ELSE.
INSERT LINES OF: lt_orderadm_h_tmp INTO TABLE lt_orderadm_h,
lt_orderadm_i_tmp INTO TABLE lt_orderadm_i,
lt_orgman_tmp INTO TABLE lt_orgman,
lt_partner_tmp INTO TABLE lt_partner,
lt_status_tmp INTO TABLE lt_status,
lt_doc_flow_tmp INTO TABLE lt_doc_flow.
ENDIF.
ENDMETHOD.
The method meth must be public, and can have only one non-optional input parameter p_task of type clike.
Did you check for ST22 errors? Those might show you what went wrong.
Hi michel,
Thanks for your reply and your help. I have solved it.
Added WAIT UNTIL in code after call function statement.
set a counter to keep track of tasks active by incrementing counter at new task started and
decrementing counter at end of results received
| User | Count |
|---|---|
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.