If you wish to SUBMIT a program you can do so by using the SUBMIT statement or you can use the following function module. Once the called program executes the control is returned to the calling program.
RZL_SUBMIT
Please find the code below.
REPORT ZEX_FUNCCALLPROG .
Parameters: p_prog like sy-repid.
CALL FUNCTION 'RZL_SUBMIT' EXPORTING REPID = p_prog .
If you wish to retrieve the selection Parameters of a report and print them at the end of the report then you can use the following function Module.
RS_COVERPAGE_SELECTIONS
To use this Function Module you need to create a variant for the the report. There can be multiple variants for a single report, but the selection screen will get printed fro the one that is used currently for running the report.
Please note that code related to this function module is marked in Brown.
REPORT ZEX_PAYMENTDETAILS1.
* Tables declaration TABLES:bsak, "Accounting: Secondary Index for Vendors (Cleared Items) payr, "Payment Medium File lfa1. "Vendor Master (General Section)
TYPE-POOLS : slis. * Type Declaration TYPES : BEGIN OF etab, bukrs LIKE bsak-bukrs, augdt LIKE bsak-augdt, xblnr LIKE bsak-xblnr, belnr LIKE bsak-belnr, bldat LIKE bsak-bldat, lifnr LIKE bsak-lifnr, name1 LIKE lfa1-name1, augb1 LIKE bsak-augbl, rwbtr LIKE payr-rwbtr, waers LIKE payr-waers, chect LIKE payr-chect, zaldt LIKE payr-zaldt, hbkid LIKE payr-hbkid, END OF etab. * Internal Tables DATA : tab_etab TYPE STANDARD TABLE OF etab, wa_etab TYPE etab, d_prog like sy-repid.
Data: Begin of int_infotab occurs 0, Field1(100), End of int_infotab.
* Data Declaration DATA: wa_fieldcat TYPE slis_fieldcat_alv, it_fieldcat TYPE slis_t_fieldcat_alv, wa_event TYPE slis_alv_event, it_events TYPE slis_t_event, wa_line TYPE slis_listheader, it_line TYPE slis_t_listheader, wa_sort TYPE slis_sortinfo_alv, it_sort TYPE slis_t_sortinfo_alv.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS s_ccode FOR bsak-bukrs ."OBLIGATORY. SELECTION-SCREEN SKIP 1. SELECT-OPTIONS s_pdate FOR bsak-augdt. SELECT-OPTIONS s_drence FOR bsak-xblnr.
SELECTION-SCREEN END OF BLOCK b1.
START-OF-SELECTION.
PERFORM select.
PERFORM build_fcat.
PERFORM display.
PARAMETERS: p_file LIKE rlgrap-filename DEFAULT 'H:\TESTSAP.xls'.
move: sy-repid to d_prog.
CALL FUNCTION 'RS_COVERPAGE_SELECTIONS' EXPORTING REPORT = d_prog VARIANT = sy-slset * NO_IMPORT = ' ' TABLES INFOTAB = int_infotab EXCEPTIONS ERROR_MESSAGE = 1 VARIANT_NOT_FOUND = 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.
IF sy-subrc <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF.
ENDFORM.
*---------------------------------------------------------------------* * FORM select * *---------------------------------------------------------------------* * ........ * *---------------------------------------------------------------------* FORM select.
SELECT bsak~bukrs bsak~augdt bsak~xblnr bsak~belnr bsak~bldat bsak~lifnr bsak~bschl bsak~xstov payr~rwbtr payr~waers payr~chect payr~zaldt payr~hbkid FROM bsak INNER JOIN lfa1 ON bsak~lifnr = lfa1~lifnr INNER JOIN payr ON bsak~augbl = payr~vblnr AND bsak~gjahr = payr~gjahr INTO TABLE tab_etab WHERE bukrs IN s_ccode AND augdt IN s_pdate AND xblnr IN s_drence AND bsak~bschl = 31 AND bsak~xstov = ''.
Always use Pretty Printer and Extended Program Check before releasing the code.
Do not leave unused code in the program. Comment the code thoroughly. Align the comments and the Code. Follow the SAP Standards and SAP Best Practices guidelines. It’s a good practice to take a dump of the code on your local drive.