Submit a program and write its report in your program

Submit a program and write its report in your program

This post explain how to call another report in your report and how to print it SPOOL in your program.


* Declaration of variables
  DATA:li_listobject TYPE STANDARD TABLE OF abaplist.

* Initialization
  REFRESH: li_listobject.

* Submit program to update values 

* and get the output of loading program displayed in this report
  SUBMIT Program_Name EXPORTING LIST TO MEMORY
  AND RETURN.

* Get the output from the submit
  CALL FUNCTION 'LIST_FROM_MEMORY'
    TABLES
      listobject = li_listobject
    EXCEPTIONS
      not_found  = 1
      OTHERS     = 2.
  IF  sy-subrc <> 0.
    REFRESH li_listobject.
  ENDIF.
  WRITE:/ 'Spool of {Program_Name} :'.
  SKIP.

* Display the output report of program
* display list
  CALL FUNCTION 'WRITE_LIST'
    TABLES
      listobject = li_listobject
    EXCEPTIONS
      empty_list = 1
      OTHERS     = 2.
  IF  sy-subrc <> 0.
    REFRESH li_listobject.
  ENDIF.

* Delete list to memory
  CALL FUNCTION 'LIST_FREE_MEMORY'
    TABLES
      listobject = li_listobject.

About the author

fjourneau administrator

Hi, I'm Florian Journeau, SAP ABAP R3 Freelance, based in Toulouse, France. You want to know more about me, have a look on my CV : cv.fjourneau.net.

Leave a Reply