Wednesday, 3 September 2014

Parallel Processing In OOabap

Step1. Create a report with class and methods.
---------------------------------------------------------------------------------------------------------------------------------

REPORT  zparallel_processing_oo.

DATA chk1,
              chk2,
              ret11 TYPE TABLE OF  bapisdstat,
              ret22 TYPE TABLE OF  bapisdstat,
              ret TYPE  bapisdstat.

******************************************************
CLASS lcl_demo DEFINITION.
  PUBLIC SECTION.

    CLASS-METHODS call IMPORTING sdoc1 TYPE bapivbeln-vbeln
                                                                      sdoc2 TYPE bapivbeln-vbeln ,
                    handle1 IMPORTING p_task TYPE clike, " must have a importing para- of type clike
                    handle2 IMPORTING p_task TYPE clike. " 
must have a importing para- of type clike
ENDCLASS.                    "LCL_DEMO DEFINITION


*----------------------------------------------------------------------*
*       CLASS LCL_DEMO IMPLEMENTATION
*----------------------------------------------------------------------*
CLASS lcl_demo IMPLEMENTATION.
  METHOD call.
    CALL FUNCTION 'BAPI_SALESORDER_GETSTATUS'
      STARTING NEW TASK 'FUNC1'
      DESTINATION 'NONE'
      CALLING handle1 ON END OF TASK
      EXPORTING
        salesdocument sdoc1.

    CALL FUNCTION 'BAPI_SALESORDER_GETSTATUS'
      STARTING NEW TASK 'FUNC2'
      DESTINATION 'NONE'
      CALLING handle2 ON END OF TASK
      EXPORTING
        salesdocument sdoc2.
    WAIT UNTIL  chk1 abap_true AND chk2 abap_true.

    WRITE :'SUCCESS'.

  ENDMETHOD.                    "CALL


  METHOD handle1.
    DATAret1 TYPE TABLE OF bapisdstat.
    RECEIVE RESULTS FROM FUNCTION 'BAPI_SALESORDER_GETSTATUS'
    TABLES
    statusinfo        ret1.
    ret11 ret1.
    chk1 abap_true.

  ENDMETHOD.                    "HANDLE1



  METHOD handle2.
    DATAret2 TYPE TABLE OF bapisdstat.
    RECEIVE RESULTS FROM FUNCTION 'BAPI_SALESORDER_GETSTATUS'
    TABLES
    statusinfo        ret2.
    ret22 ret2.
    chk1 abap_true.

  ENDMETHOD.                    "HANDLE2

ENDCLASS.                    "LCL_DEMO IMPLEMENTATION

START-OF-SELECTION.
  PARAMETERSp_sdoc1 TYPE bapivbeln-vbeln,
                               p_sdoc2 TYPE bapivbeln-vbeln.

  CALL METHOD lcl_demo=>call
    EXPORTING
      sdoc1 p_sdoc1
      sdoc2 p_sdoc2.

  LOOP AT ret11 INTO ret.
    WRITE :/ ret-doc_number ret-materialret-creation_date.
  ENDLOOP.
  CLEAR ret.
  LOOP AT ret22 INTO ret.
    WRITE :/ ret-doc_number ret-materialret-creation_date.
  ENDLOOP.


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


Step2. The screen shot of the report.





































Step3. Provide the Input and execute it.












Step4. THe O?p is shown below.













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


No comments:

Comments system

Disqus Shortname