cancel
Showing results for 
Search instead for 
Did you mean: 

sap script

Former Member
0 Kudos

hi all

i have to generate a report through script

i have created form with HEADER, MAIN and FOOTER.

in the Header window i should get logo and heading for the report in center.

in the FOOTER window i should get page number

in the MAIN window i should get as below

Customer Name Country

values values values

values values values

values values values

values values values

......... ........ .........

now in print program i took all these fields into internal table.

Can any one tell me wat to write in print program once we get all the values into internal table. And how to call those values in form.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Once you get the values in the internal table..Then call the sap script function modules..

Example

-


CALL FUNCTION 'OPEN_FORM'

EXPORTING

form = <b>'Sapscript form name'</b>

language = sy-langu

EXCEPTIONS

canceled = 1

device = 2

form = 3

options = 4

unclosed = 5

OTHERS = 11.

LOOP AT ITAB.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

element = <b>'Give the text element name'</b>

window = 'MAIN'

EXCEPTIONS

element = 1

function = 2

type = 3

unopened = 4

unstarted = 5

window = 6

bad_pageformat_for_print = 7

spool_error = 8

OTHERS = 9.

ENDLOOP.

CALL FUNCTION 'CLOSE_FORM'

EXCEPTIONS

unopened = 1

bad_pageformat_for_print = 2

OTHERS = 5.

Thanks,

Naren

Former Member
0 Kudos

What should i write in the main window

ie in Text element

Former Member
0 Kudos

hi satya,

check this sample code...

PRINT PROGRAM

*********************************************************************

<b>REPORT z_script_prog .

TABLES: mseg.

DATA: itab LIKE mseg OCCURS 3 WITH HEADER LINE.

SELECT * FROM mseg INTO TABLE itab.

SORT itab BY matnr.

DELETE ADJACENT DUPLICATES FROM itab COMPARING matnr.

CLEAR itab.

PERFORM oform.

PERFORM sform.

LOOP AT itab INTO mseg.

PERFORM wform.

ENDLOOP.

PERFORM eform.

PERFORM cform.

&----


*& Form oform

&----


  • text

----


FORM oform.

CALL FUNCTION 'OPEN_FORM'

EXPORTING

form = 'ZSAB' " UR SAPSCRIPT NAME

language = sy-langu.

ENDFORM. "oform

&----


*& Form sform

&----


  • text

----


FORM sform.

CALL FUNCTION 'START_FORM'

EXPORTING

  • ARCHIVE_INDEX =

form = 'ZSAB' " UR SAPSCRIPT NAME

language = sy-langu

startpage = 'PAGE1'

.

ENDFORM. "sform

&----


*& Form wform

&----


  • text

----


FORM wform.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

element = 'DATA' " UR TEXT ELEMENT NAME

function = 'SET'

type = 'BODY'

window = 'MAIN'.

ENDFORM. "wform

FORM eform.

CALL FUNCTION 'END_FORM'.

ENDFORM. "eform

&----


*& Form cform

&----


  • text

----


FORM cform.

CALL FUNCTION 'CLOSE_FORM'.

ENDFORM. "cform</b>

*************************************************************************************

SCRIPT PROGRAM - MAIN WINDOW

**************************************************************************

<b>/E DATA " UR TEXT ELEMENT NAME

PR Material Number : &mseg-matnr&

PR Plant: &mseg-werks&

PR Storage Location : &mseg-lgort&</b>

***************************************************

WHERE PR is a paragraph format... if u dont create one then u can use *.

Regards

SAB

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Go to the MAIN window..And give the following..

Sap script changes

-


/E LINEITEM_HEADER

P1 Customer Name Country

/E LINEITEM_DETAIL

P1 &ITAB-KUNNR& &ITAB-NAME& &ITAB-LAND1&

Print program changes

-


LOOP AT ITAB.

AT FIRST.

  • Print the header..

CALL FUNCTION 'WRITE_FORM'

EXPORTING

element = LINEITEM_HEADER

window = 'MAIN'.

ENDAT.

  • Print the customer details

CALL FUNCTION 'WRITE_FORM'

EXPORTING

element = LINEITEM_DETAIL

window = 'MAIN'.

ENDLOOP.

Hope this helps..

Thanks,

Naren