Skip to Content
author's profile photo Former Member
Former Member

SAPScript output

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Sep 27, 2005 at 07:21 PM

    Hi

    How have you define your paragraphs?

    Max

    Message was edited by: max bianchi

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi,

      These is how i define the paragraphs.

      Paragraphs Attributes

      P1 Default Paragraph

      Standard attributes

      Line spacing 1.00 LN

      Left margin 1.00 CM

      Alignment Left-aligned

      Font attributes

      Font family TIMES

      Font size 12.0 Point

      P2 Header Paragraph

      Standard attributes

      Line spacing 1.00 LN

      Left margin 4.50 CM

      Alignment Left-aligned

      Font attributes

      Font family TIMES

      Font size 18.0 Point

      Bold Yes

      P3 Undelined paragraph

      Standard attributes

      Line spacing 1.00 LN

      Alignment Left-aligned

      Font attributes

      Font family TIMES

      Font size 12.0 Point

      Underlined Yes

      Thanks,

      Sriram.

  • author's profile photo Former Member
    Former Member
    Posted on Sep 27, 2005 at 07:22 PM

    Sriram - I think you need to call FM START_FORM after the call to OPEN_FORM and also END_FORM before CLOSE_FORM.

    Rob

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Sriram

      I run your code and it works fine.

      Try to delete the rows of code where you define print parameters and set the parameter DIALOG of OPEN_FORM

      and this statament is wrong

      POSITION XORIGIN 2 CM YORIGIN '-0.5 CM'

      but it should be:

      POSITION XORIGIN 2 CM YORIGIN '-0.5' CM

      Max

      Message was edited by: max bianchi

  • author's profile photo Former Member
    Former Member
    Posted on Sep 27, 2005 at 08:58 PM

    Are you doing the print preview from the SAPScript screen (SE71) or after the execution of your program?

    Rob

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.