cancel
Showing results for 
Search instead for 
Did you mean: 

SAP script

Former Member
0 Kudos

Hi,

My requirement is to develop a script and get print(data should tranfer to script main window or body) from a Report.

i.e ALV report contains a button for print, when we click this, the report output should be printed in a script format which is designed for it.

am quite new to script development. Could you please provide some inputs here?

Thanks

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Please close your other thread. Do not post duplicate threads.

Regards,

Vara

Former Member
0 Kudos

HI,

when u r displaying the alv output means u have final internal table.

when u press print button in alv .. add the code to print sapscript for that button.

here is sample code..

<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. "OPEN FORM

PERFORM sform. " START FORM

LOOP AT itab INTO mseg.

PERFORM wform. " WRITE FORM

ENDLOOP.

PERFORM eform. " END FORM

PERFORM cform. " CLOSE FORM

&----


*& Form oform

&----


  • text

----


FORM oform.

CALL FUNCTION 'OPEN_FORM'

EXPORTING

form = 'ZSAB' " UR FORM NAME

language = sy-langu.

ENDFORM. "oform

&----


*& Form sform

&----


  • text

----


FORM sform.

CALL FUNCTION 'START_FORM'

EXPORTING

  • ARCHIVE_INDEX =

form = 'ZSAB' "UR FORM NAME

language = sy-langu

startpage = 'PAGE1'

.

ENDFORM. "sform

&----


*& Form wform

&----


  • text

----


FORM wform.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

element = 'DATA' " UR TEXT ELEMENT IN MAIN WINDOW

function = 'SET'

type = 'BODY'

window = 'MAIN'.

ENDFORM. "wform

*form tform.

*

FORM eform.

CALL FUNCTION 'END_FORM'

.

ENDFORM. "eform

&----


*& Form cform

&----


  • text

----


FORM cform.

CALL FUNCTION 'CLOSE_FORM'

.

ENDFORM. "cform</b>

Please close the thread if the problem is solved and please do not post duplicate threads.

Regards

SAB