How to get output from report-1 without execute it. And get the output using SUBMIT statement

In this sample we will get the output of report-1(zelvr_test_report) without execute it. To get the rep1 output we will write some logic in program-1(zelvr_test_submit).
Report-1
*&---------------------------------------------------------------------*
*& Report ZELVR_TEST_SUBMIT
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT zelvr_test_report.
TYPE-POOLS : slis.

DATA : lt_vbak TYPE STANDARD TABLE OF vbak.
DATA : lt_fieldcatlog TYPE slis_t_fieldcat_alv.

SELECT * FROM vbak INTO TABLE lt_vbak UP TO 100 ROWS.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
   i_program_name               = sy-repid
   i_structure_name             = 'VBAK'
 CHANGING
   ct_fieldcat                  = lt_fieldcatlog
EXCEPTIONS
  inconsistent_interface       = 1
  program_error                = 2
  OTHERS                       = 3
         .

DELETE lt_fieldcatlog WHERE col_pos > 5. ”Delete all column except Sale Doc. No., Created date, time & Name

IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
 EXPORTING
   i_callback_program = sy-repid
   it_fieldcat        = lt_fieldcatlog
 TABLES
   t_outtab           = lt_vbak
 EXCEPTIONS
   program_error      = 1
   OTHERS             = 2.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Report-1 Output


Program-1

Steps to read called program output into internal table defined in the calling program. 
·         Use syntax addition "EXPORTING LIST TO MEMORY AND RETURN" to SUBMIT statement. This addition stores the basic list for the program accessed in the ABAP Memory. It can only be used together with the addition AND RETURN. The list is stored in the ABAP Memory as an internal table of the row type ABAPLIST. ABAPLIST is a structured data type in ABAP Dictionary.
·         Use the function module LIST_FROM_MEMORY to load the list from the ABAP Memory to an internal table of the row type ABAPLIST.
·         Use the function module LIST_TO_ASCI to convert the content of an internal table of the row type ABAPLIST to ASCII representation.
·         Please check the below screen shots to see data in table before and after LIST_TO_ASCI function module is used. 

*&---------------------------------------------------------------------*
*& Report ZELVR_TEST_SUBMIT
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zelvr_test_submit.

DATA : list TYPE TABLE OF abaplist.

DATA: BEGIN OF listasci OCCURS 5000,
       default(256) TYPE c,
     END OF listasci.

DATA : lv_tot_recs(5) TYPE n.

DATA : lv_erdat(10)   TYPE c.
DATA : lv_erzet(10)   TYPE c.

TYPES : BEGIN OF ty_vbak,
       vbeln TYPE vbak-vbeln,
       erdat TYPE vbak-erdat,
       erzet TYPE vbak-erzet,
       ernam TYPE vbak-ernam,
       END OF ty_vbak.

DATA : lt_vbak_c TYPE STANDARD TABLE OF ty_vbak,
      wa_vbak_c TYPE ty_vbak.

DATA : lv_dummy01(50) TYPE c.

SUBMIT zelvr_test_report EXPORTING LIST TO MEMORY AND RETURN.    "Call the report (zelvr_test_report)

CALL FUNCTION 'LIST_FROM_MEMORY'
 TABLES
   listobject = list
 EXCEPTIONS
   not_found  = 1
   OTHERS     = 2.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

CALL FUNCTION 'LIST_TO_ASCI'
* EXPORTING
*   LIST_INDEX               = -1
*   WITH_LINE_BREAK          = ' '
* IMPORTING
*   LIST_STRING_ASCII        =
*   LIST_DYN_ASCII           =
TABLES
  listasci                 = listasci
  listobject               = list
EXCEPTIONS
  empty_list               = 1
  list_index_invalid       = 2
  OTHERS                   = 3
         .
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

CALL FUNCTION 'LIST_FREE_MEMORY'
 TABLES
   listobject = list.
DESCRIBE TABLE listasci LINES lv_tot_recs.
BREAK-POINT.
LOOP AT listasci.
 CHECK sy-tabix GT 3 AND sy-tabix LT lv_tot_recs.
 IF sy-tabix = 4.
   SPLIT listasci AT '|' INTO lv_dummy01
                              lv_dummy02.
   IF lv_dummy02 CS 'List Contains no data'.
     EXIT.
   ENDIF.
 ENDIF.
 " Split pipe delimited data
 SPLIT listasci AT '|' INTO lv_dummy01
                            wa_vbak_c-vbeln
                            lv_erdat
                            lv_erzet
                            wa_vbak_c-ernam
                             .


 CONCATENATE lv_erdat+6(4) lv_erdat+3(2) lv_erdat+0(2) INTO wa_vbak_c-erdat.  "YYYYMMDD
 CONCATENATE lv_erzet+0(2) lv_erzet+3(2) lv_erzet+6(2) INTO wa_vbak_c-erzet.  "HHMMSS

 APPEND wa_vbak_c TO lt_vbak_c.
 CLEAR  : wa_vbak_c, lv_erdat.
ENDLOOP.

DELETE lt_vbak_c WHERE vbeln IS INITIAL.
BREAK-POINT.

Program-1 List internal table content (ABAP memory content)

Program-1 LIST to LISTASCI conversion internal table content using FM LIST_TO_ASCI




Program-1 Debug view



Program-1 After final loop content is look like in below format.









Share this

Related Posts