Wednesday 3 September 2014

Parallel Processing In Procedural ABAP

Parallel Processing : when a huge number of records needs to be processed and it takes a lot of time to produce the output, this parallel processing technique can be applied to achieve run time improvement. So this Parallel processing is an asynchronous call to the Function Module in parallel sessions/ different session/ multiple sessions.

--------------------------------------------------------------------------------------------------------------------------
Step1. Create the below report and execute it.

REPORT  zparallel_processing.
DATAchk1chk2.

DATAstat1 TYPE TABLE OF bapisdstat,
              stat2 TYPE TABLE OF bapisdstat,
              stat TYPE  bapisdstat.

PARAMETERSp_sdoc1 TYPE bapivbeln-vbeln,
                            p_sdoc2 TYPE bapivbeln-vbeln.


START-OF-SELECTION.
  CALL FUNCTION 'BAPI_SALESORDER_GETSTATUS'
    STARTING NEW TASK 'TASK1'
    DESTINATION 'NONE'
    PERFORMING call1 ON END OF TASK
    EXPORTING
      salesdocument p_sdoc1.


  CALL FUNCTION 'BAPI_SALESORDER_GETSTATUS'
    STARTING NEW TASK 'TAKS2'
    DESTINATION 'NONE'
    PERFORMING call2 ON END OF TASK
    EXPORTING
      salesdocument p_sdoc2.

* Receive all asynchronous replies from the FMs
* Without wait statement the subroutines: call1 / call2  will not be triggered
* Either a logical wait condition or a wait condition with soem time
* able to trigger the Subroutines call1/ call2.
  WAIT UNTIL chk1 abap_true
         AND chk2 abap_true.

* wait UP TO 10 SECONDS.
  LOOP AT stat1 INTO stat.
    WRITE :/ stat-doc_number stat-materialstat-net_price.
  ENDLOOP.
  CLEAR stat.
  LOOP AT stat2 INTO stat.
    WRITE :/ stat-doc_number stat-materialstat-net_price.
  ENDLOOP.


*&---------------------------------------------------------------------*
*&      Form  call1
*&---------------------------------------------------------------------*
FORM call1 USING taskname.
  RECEIVE RESULTS FROM FUNCTION 'BAPI_SALESORDER_GETSTATUS'
   TABLES
    statusinfo        stat1.
  chk1 abap_true.
ENDFORM.                   

*&---------------------------------------------------------------------*
*&      Form  call2
*&---------------------------------------------------------------------*

FORM call2 USING taskname.
  RECEIVE RESULTS FROM FUNCTION 'BAPI_SALESORDER_GETSTATUS'
   TABLES
      statusinfo       stat2.
  chk2 abap_true.
ENDFORM
.                 

--------------------------------------------------------------------------------------------------------------------------
Step1.1 - If you want to debug it then put a breakpoint and execute it.







































Step2. Provide the input as sale orders and execute it.












Step3. Press F5 button twice and the FM will open in two different external sessions.






























Step4. In SM50 tcode also we can can found the program and the FMs are in debugging mode.



















Step5. At last we observe this output.












-------------------------------------------------------------------------------------------------------------------------





























Step3.

Comments system

Disqus Shortname