Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

SAPScript output

Former Member
0 Kudos

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

11 REPLIES 11

Former Member
0 Kudos

Hi

How have you define your paragraphs?

Max

Message was edited by: max bianchi

0 Kudos

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.

Former Member
0 Kudos

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

Rob

0 Kudos

Hi Rob,

Can you please tell me what are the parameters i have to choose if i use the Start_from and end_form.

As I provided the program names also.

Thanks,

Sriram.

0 Kudos

Hi

It usually use FM Start_form/end_form when you want to indicate to the system when print of document starts and when it finishes.

For example if you have to print many documents, you have a data of a document in avery record of internal table, so you print all document in a loop:

OPEN_FORM

LOOP AT T_DOCUMET.

START_FORM

WRITE_FORM

WRITE_FORM

.....

END_FORM

ENDLOOP.

CLOSE_FORM

By START_FORM/END_FORM the system can understand the print of new document is beginning so it can initialize all system variable.

Max

0 Kudos

Sriram -

call function 'START_FORM'
       exporting
            form      = layout
            language  = sy-langu
            startpage = 'PAGE1'
       exceptions
            form      = 01
            format    = 02
            unended   = 03
            unopened  = 04
            unused    = 05.

form form_end.
  call function 'END_FORM'
       exceptions
            unopened = 01.

Where 'layout' is your SAPScript form and PAGE1 is the first page defined in that form. I'm not sure if you have to use them if you are sure you are only printing one form per run of the program.

Rob

0 Kudos

Hi,

In my example the output will be the only one.

Let us assume that if i have many records and i didnot mention Open form/loop at, atleast either the last record or first should print, but in my output it is printing only the code for main, header and Footer as i mentioned above. Can u check my code for defining the Header, Main and Footer.

Thanks,

Sriram.

0 Kudos

Hi

I ryn your code and it didn't print the data, I believe the problem is in the print parameter you transfer to fm open_form:

REPORT ZPSAPSCRIPT.

.......

ZOPTION-TDPROGRAM = 'ZPQRPRNT'.

Your report is called ZPSAPSCRIPT, but you transfer ZPQRPRNT, so you should write:

ZOPTION-TDPROGRAM = 'ZPSAPSCRIPT'

and your sapscript'll work fine

Max

Message was edited by: max bianchi

Message was edited by: max bianchi

0 Kudos

Hi Max,

I tried using the same even though the out put was the same no change in it.

Sriram.

0 Kudos

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

Former Member
0 Kudos

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

Rob