REPORT ZPSAPSCRIPT.
TABLES : EKKO,
EKPO,
KNA1,
USR01,
MARA,
MAKT.
DATA : BEGIN OF ZOPTION.
INCLUDE STRUCTURE ITCPO.
DATA : END OF ZOPTION.
PARAMETERS: P_EBELN LIKE EKKO-EBELN,
P_EBELP LIKE EKPO-EBELP.
CLEAR EKPO.
SELECT SINGLE * FROM EKPO
WHERE EBELN = P_EBELN AND
EBELP = P_EBELP.
CLEAR KNA1.
SELECT SINGLE NAME1 FROM KNA1
INTO KNA1-NAME1
WHERE KUNNR = EKPO-KUNNR.
CLEAR MAKT.
SELECT SINGLE MAKTX FROM MAKT
INTO MAKT-MAKTX
WHERE MATNR = EKPO-MATNR AND
SPRAS = SY-LANGU.
CLEAR USR01.
SELECT SINGLE * FROM USR01 WHERE BNAME = SY-UNAME.
ZOPTION-TDDEST = USR01-SPLD. "Output device (printer)
ZOPTION-TDIMMED = 'X'. "Print immediately
ZOPTION-TDDELETE = 'X'. "Delete after printing
ZOPTION-TDPROGRAM = 'ZPQRPRNT'. "Program Name
CALL FUNCTION 'OPEN_FORM'
EXPORTING
APPLICATION = 'TX'
* ARCHIVE_INDEX = ' '
* ARCHIVE_PARAMS = ' '
DEVICE = 'PRINTER'
DIALOG = ' '
FORM = 'Z_TESTSCRIPT'
LANGUAGE = SY-LANGU
OPTIONS = ZOPTION
IMPORTING
LANGUAGE = SY-LANGU
EXCEPTIONS
OTHERS = 1.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'HEADER'
* FUNCTION = 'SET'
* TYPE = 'BODY'
WINDOW = 'HEADER'
EXCEPTIONS
ELEMENT = 1.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'MAIN'
* FUNCTION = 'SET'
* TYPE = 'BODY'
WINDOW = 'MAIN'
EXCEPTIONS
ELEMENT = 1.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'FOOTER'
* FUNCTION = 'SET'
* TYPE = 'BODY'
WINDOW = 'FOOTER'
EXCEPTIONS
ELEMENT = 1.
CALL FUNCTION 'CLOSE_FORM'
EXCEPTIONS
UNOPENED = 1
OTHERS = 2.