Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
kishorekumar_vemula
Active Participant

Most of the time when dealing with huge amount of data, the run time / execution time of a program should be with in the specified time limit. To overcome this, SAP has provided a wonderful tool called "Parallel processing".

My attempt to provide an example for parallel processing.

Requirement:
Get the list of Contracts (New, Terminated and Active as on date) for a given period and retrieve the additional information using parallel processing.

Solution:

Requirement is seems to be simple. But, yes scanning CRMD_ORDERADM_H for all the contracts and retrieving the additional data (Partner, Product, Customer etc..) for each contract is not an easy and quick task.

Parallel processing has been introduced to complete the report with in the specified time.

Selection Screen:


Parallel processing code:
  1. Do the Initial selection of contracts based on the Period.

  2. Call the FM 'SPBT_INITIALIZE' to know the Maximum work process and free work process by passing the server group name (parallel_generators)

  3. Note: For server group details, the number of maximum work process you can use under this group are best answered by your BASIS team. In practice, BASIS will provide a dedicated application sever group for parallel processing.

  4. Based on the selection screen entry (number of records per call),  move these many records into an internal table for parallel processing.

  5. If you want to track the number of records processed, use below statements to see the job log while the program is running.

  6. CONCATENATE 'Total Records to be processed are' lv_gtot INTO lv_string.
       MESSAGE lv_string TYPE 'I'.

  7. Here lv_gtot is the number of lines of the internal table which is passed to parallel processing FM

  8. Retrieve the resources info by calling FM 'SPBT_GET_CURR_RESOURCE_INFO' and check against the selection screen entry "Maximum no of work process to be used".

  9. If the available work process is greater than specified, and the running work process are within the max limit, call the RFC Function module in Asynchronous mode. If not wait for the free work process and try again.

  10. When the RFC is called, please check the returned sy-subrc value. If it is initial, count the number of submitted RFC.

  11. Continue the submission of Asynchronous RFC till all the records are processed.

  12. The RFC is executed in the next available work process in the said server group and the results are captured under "Call back routine" ON END OF TASK.

  13. In the receiving routine count the number of RFC received.

  14. As this is asynchronous calls, we need to wait until the number of sent calls and received should be equal.

Code snippet:

Perform f_init_server_group screen shot attached at the top of the page.

     Here in below, we are calling the RFC Function module which does the actual work. It retries the all the requested information for the passed chunk of data.

     Once the FM is executed fully, then the call back routine "f_call_back*" is called.

     In the below call back routine, we will capture the processed records with all the information.

     The final internal table gt_*_in2 will holds the all the information.

      If any data base update is required then it should be done in the RFC itself.

      For tracking of the records processed, use "MESSAGE" statement where ever required.

      And last but not least, don't forget to wait till the sent RFC calls should be equal to received RFC Calls.

9 Comments