Passing table data to the layout without changing the driver program

...Previous

Run the custom report to test the SAPscript layout.

*&---------------------------------------------------------------*
*& Report  Z_TEST_SAPCSRIPT                                            *
*&---------------------------------------------------------------*
REPORT  Z_TEST_SAPCSRIPT                        .
start-of-selection.
CALL FUNCTION 'OPEN_FORM'
 EXPORTING
   DEVICE                            = 'PRINTER'
   DIALOG                            = 'X'
   FORM                              = 'Z_DEMO_LAYOUT' 
   LANGUAGE                          = SY-LANGU
 EXCEPTIONS
   CANCELED                          = 1
   DEVICE                            = 2
   FORM                              = 3
   OPTIONS                           = 4
   UNCLOSED                          = 5
   MAIL_OPTIONS                      = 6
   ARCHIVE_ERROR                     = 7
   INVALID_FAX_NUMBER                = 8
   MORE_PARAMS_NEEDED_IN_BATCH       = 9
   SPOOL_ERROR                       = 10
   CODEPAGE                          = 11
   OTHERS                            = 12
          .
IF sy-subrc = 0.
CALL FUNCTION 'WRITE_FORM'
 EXPORTING
   ELEMENT                        = '001'
   FUNCTION                       = 'SET'
   TYPE                           = 'BODY'
   WINDOW                         = 'MAIN'
* IMPORTING
*   PENDING_LINES                  =
 EXCEPTIONS
   ELEMENT                        = 1
   FUNCTION                       = 2
   TYPE                           = 3
   UNOPENED                       = 4
   UNSTARTED                      = 5
   WINDOW                         = 6
   BAD_PAGEFORMAT_FOR_PRINT       = 7
   SPOOL_ERROR                    = 8
   CODEPAGE                       = 9
   OTHERS                         = 10
          .
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 'CLOSE_FORM'
  EXCEPTIONS
    UNOPENED                       = 1
    BAD_PAGEFORMAT_FOR_PRINT       = 2
    SEND_ERROR                     = 3
    SPOOL_ERROR                    = 4
    CODEPAGE                       = 5
    OTHERS                         = 6
           .
 IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
 ENDIF.
ENDIF.

After execution of this report SAPscript debugger is triggered.

 

As shown below layout is calling the code written in the routine

 

Standard text is populated with the data fetched from table

 

Output of SAP script: 

 

Table entries:

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image