Skip to Content
0
Former Member
Sep 27, 2005 at 07:12 PM

SAPScript output

26 Views

Hi,

This is my example.

In Sapscript the name of the form is Z_TESTSCRIPT.

Text elements for following windows:

HEADER

Element HEADER

/: POSITION XORIGIN 2 CM YORIGIN '-0.5 CM'

/: BOX XPOS 1 CM YPOS 1 CM WIDTH 18 CM HEIGHT 1 CM FRAME 10 TW INTENSITY 10

/

/

/

P2 ,,<B>TEST PURCHASE ORDER</>

/

/

MAIN

Element MAIN

P1 <B>Customer/Supplier:</>,,&KNA1-NAME1&

/

P1 <B>PO No:</>,,&EKPO-EBELN&

/

P1 <B>Part No:</>,,&MAKT-MATNR&

/

P1 <B>Description:</>,,&MAKT-MAKTX&

/

P1 <B>Quantity:,,</>&EKPO-MENGE&

/

P1 <B>Sign:</>&uline(81)&

/

P1 <B>Date:</>&EKKO-AEDAT&

FOOTER

Element FOOTER

/: POSITION XORIGIN 2 CM YORIGIN '-0.5 CM'

/: BOX XPOS 1 CM YPOS 1 CM WIDTH 18 CM HEIGHT 1 CM FRAME 10 TW INTENSITY 10

/

/

/

P2 ,,<B>PLEASE SIGN THE PO BEFORE DISPATCH</>

/

/

And the ABAP Program name is ZPSAPSCRIPT.

And the code is like this.

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.

<b>But the output, if i click on print preview button then the output is like below, but i could not see the purchase order which i have selected in the selection screen.

Element HEADER

/: POSITION XORIGIN 2 CM YORIGIN '-0.5 CM'

/: BOX XPOS 1 CM YPOS 1 CM WIDTH 18 CM HEIGHT 1 CM FRAME 10 TW INTENSITY 10

/

/

/

P2 ,,<B>TEST PURCHASE ORDER</>

/

/

Element MAIN

P1 <B>Customer/Supplier:</>,,&KNA1-NAME1&

/

P1 <B>PO No:</>,,&EKPO-EBELN&

/

P1 <B>Part No:</>,,&MAKT-MATNR&

/

P1 <B>Description:</>,,&MAKT-MAKTX&

/

P1 <B>Quantity:,,</>&EKPO-MENGE&

/

P1 <B>Sign:</>&uline(81)&

/

P1 <B>Date:</>&EKKO-AEDAT&

Element FOOTER

/: POSITION XORIGIN 2 CM YORIGIN '-0.5 CM'

/: BOX XPOS 1 CM YPOS 1 CM WIDTH 18 CM HEIGHT 1 CM FRAME 10 TW INTENSITY 10

/

/

/

P2 ,,<B>PLEASE SIGN THE PO BEFORE DISPATCH</>

/

/

Same as the coding done for the text element for the main, header and Footer.</b>

Message was edited by: sriram Ponna

Message was edited by: sriram Ponna

Message was edited by: sriram Ponna