ABAP SUBMIT to execute second SAP report



Below is example code snippet to use the ABAP SUBMIT statement within your SAP report programs so that you can execute a second report with the required values. And control whether the process flow then returns to the original report or ends with the call report.

Simple SUBMIT example

 
*&---------------------------------------------------------------------*
REPORT  ZTEST_CALL.

DATA:  lt_seltab TYPE TABLE OF rsparams,
       ls_seltab LIKE LINE OF lt_seltab.

 ls_seltab-selname = 'SO_EBELN'. "Parameter on selection screen of submitted report
 ls_seltab-KIND = 'S'.
 ls_seltab-SIGN = 'I'.
 ls_seltab-OPTION = 'EQ'.
 ls_seltab-LOW = '1234'.
* ls_seltab-HIGH =

 APPEND ls_seltab TO lt_seltab.

 SUBMIT ZTEST_SUBMIT WITH SELECTION-TABLE lt_seltab AND RETURN.

We will now try to delve a bit deeper into the submit command and provide examples of most if not all the functionality you may need to use. First here is an example ABAP report that we will use for demonstration purposes and will call this report using the SUBMIT command in various different ways.


Example program which will be used to demonstrate submit functionality


REPORT  ztest_submit.

TABLES: ekpo.

PARAMETERS:     p_val1 TYPE c DEFAULT 1,
                         p_val2 TYPE c.

SELECT-OPTIONS: so_ebeln FOR ekpo-ebeln DEFAULT 10,
                so_ebelp FOR ekpo-ebelp.

DATA: ld_lines TYPE i,
      wa_ebeln LIKE LINE OF so_ebeln,
      wa_ebelp LIKE LINE OF so_ebelp.


************************************************************************
*START-OF-SELECTION.
START-OF-SELECTION.
  WRITE: / 'P_VAL1 =', p_val1.
  WRITE: / 'P_VAL2 =', p_val2.

  SKIP 2.

  ld_lines = lines( so_ebeln ).
  WRITE: / 'SO_EBELN(lines count) =', ld_lines.
  IF ld_lines GT 0.
    WRITE:/ sy-uline(37).
  ENDIF.
  LOOP AT so_ebeln INTO wa_ebeln.
    WRITE:/  sy-vline, wa_ebeln-sign, sy-vline, wa_ebeln-option, sy-vline, 
                  wa_ebeln-low, sy-vline, wa_ebeln-high, sy-vline .
  ENDLOOP.
  IF sy-subrc EQ 0. "entries found by loop
    WRITE:/ sy-uline(36).
  ENDIF.

  SKIP 2.

  DESCRIBE TABLE  so_ebelp LINES ld_lines.
  WRITE: / 'SO_EBELP(lines count) =', ld_lines.
    IF ld_lines GT 0.
    WRITE:/ sy-uline(37).
  ENDIF.
  LOOP AT so_ebelp INTO wa_ebelp.
    WRITE:/  sy-vline, wa_ebelp-sign, sy-vline, wa_ebelp-option, sy-vline, wa_ebelp-low, sy-vline, wa_ebelp-high, sy-vline .
  ENDLOOP.
  IF sy-subrc EQ 0. "entries found by loop
    WRITE:/ sy-uline(36).
  ENDIF.

Output from this report

submit-report-output

About the Author se80