Vous êtes sur la page 1sur 6

A Sample SAP Scripts Reports

A Sample SAP Scripts Reports


Author: Mona CALL FUNCTION 'OPEN_FORM' * EXPORTING * APPLICATION = 'TX' * ARCHIVE_INDEX = * ARCHIVE_PARAMS = * DEVICE = 'PRINTER' * DIALOG = 'X' * FORM = 'ZSCRIPT1' * LANGUAGE = SY-LANGU * OPTIONS = * MAIL_SENDER = * MAIL_RECIPIENT = * MAIL_APPL_OBJECT = * RAW_DATA_INTERFACE = '*' * SPONUMIV = * IMPORTING * LANGUAGE = * NEW_ARCHIVE_PARAMS = * RESULT = EXCEPTIONS CANCELED = 1 DEVICE = 2 FORM = 3 OPTIONS = 4 UNCLOSED = 5 MAIL_OPTIONS = 6 ARCHIVE_ERROR = 7 INVALID_FAX_NUMBER = 8 MORE_PARAMS_NEEDED_IN_BATCH = 9 SPOOL_ERROR = 10 CODEPAGE = 11 OTHERS = 12 . IF SY-SUBRC <> 0. MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF.

http://www.sap-img.com/sapscripts/a-sample-sap-scripts-reports.htm (1 of 6) [4/10/2008 4:38:38 PM]

A Sample SAP Scripts Reports

CALL FUNCTION 'START_FORM' EXPORTING * ARCHIVE_INDEX = FORM = 'ZFORM1' * LANGUAGE = ' ' * STARTPAGE = 'X' PROGRAM = 'ZSCRIPT1' * MAIL_APPL_OBJECT = * IMPORTING * LANGUAGE = * EXCEPTIONS * FORM = 1 * FORMAT = 2 * UNENDED = 3 * UNOPENED = 4 * UNUSED = 5 * SPOOL_ERROR = 6 * CODEPAGE = 7 * OTHERS = 8 . IF SY-SUBRC <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. CALL FUNCTION 'WRITE_FORM' EXPORTING * ELEMENT * FUNCTION * TYPE WINDOW * IMPORTING * PENDING_LINES EXCEPTIONS ELEMENT FUNCTION TYPE UNOPENED UNSTARTED WINDOW BAD_PAGEFORMAT_FOR_PRINT SPOOL_ERROR OTHERS

= ' ' = 'SET' = 'BODY' = 'HEADER' = = = = = = = = = = 1 2 3 4 5 6 7 8 9

http://www.sap-img.com/sapscripts/a-sample-sap-scripts-reports.htm (2 of 6) [4/10/2008 4:38:38 PM]

A Sample SAP Scripts Reports

. IF SY-SUBRC <> 0. write:/ 'ERROR IN HEADER'. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. CALL FUNCTION 'WRITE_FORM' EXPORTING * ELEMENT * FUNCTION * TYPE WINDOW * IMPORTING * PENDING_LINES EXCEPTIONS ELEMENT FUNCTION TYPE UNOPENED UNSTARTED WINDOW BAD_PAGEFORMAT_FOR_PRINT SPOOL_ERROR OTHERS . IF SY-SUBRC <> 0. write:/ 'ERROR IN HEADER'.

= ' ' = 'SET' = 'BODY' = 'MAIN' = = = = = = = = = = 1 2 3 4 5 6 7 8 9

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. CALL FUNCTION 'WRITE_FORM' EXPORTING * ELEMENT * FUNCTION * TYPE WINDOW * IMPORTING * PENDING_LINES EXCEPTIONS

= ' ' = 'SET' = 'BODY' = 'FOOTER' =

http://www.sap-img.com/sapscripts/a-sample-sap-scripts-reports.htm (3 of 6) [4/10/2008 4:38:38 PM]

A Sample SAP Scripts Reports

ELEMENT FUNCTION TYPE UNOPENED UNSTARTED WINDOW BAD_PAGEFORMAT_FOR_PRINT SPOOL_ERROR OTHERS . IF SY-SUBRC <> 0. write:/ 'ERROR IN HEADER'.

= = = = = = = = =

1 2 3 4 5 6 7 8 9

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. CALL FUNCTION 'END_FORM' * IMPORTING * RESULT * EXCEPTIONS * UNOPENED * BAD_PAGEFORMAT_FOR_PRINT * SPOOL_ERROR * CODEPAGE * OTHERS . CALL FUNCTION 'CLOSE_FORM' * IMPORTING * RESULT * RDI_RESULT * TABLES * OTFDATA * EXCEPTIONS * UNOPENED * BAD_PAGEFORMAT_FOR_PRINT * SEND_ERROR * SPOOL_ERROR * CODEPAGE * OTHERS .

= = = = = = 1 2 3 4 5

= = = = = = = = = 1 2 3 4 5 6

http://www.sap-img.com/sapscripts/a-sample-sap-scripts-reports.htm (4 of 6) [4/10/2008 4:38:38 PM]

A Sample SAP Scripts Reports

Can you explain the difference between 1.open_form and Start form 2.end_form and Close_form. whether all 4 modules are required in the driver pgm . Open_form => It assign the form and printer, It should be first. Start_form => It start Writing mode. You can use write_form in loop to write more than one lines befor End_form. End_form => It end writing mode of current page and will require to start again through Start_form. Close_form=> it end the Form. After this you can not start again for created file. Rajiv singh. Fast Links: Get help for your ABAP problems Do you have a ABAP Question? ABAP Books ABAP Certification, BAPI, Java, Web Programming, Smart Forms, Sapscripts Reference Books

SAP Scripts Tips SAP Sapscripts Tips and Tricks Best regards, SAP Basis, ABAP Programming and Other IMG Stuff http://www.sap-img.com
All the site contents are Copyright www.sap-img.com and the content authors. All rights reserved. All product names are trademarks of their respective companies. The site www.sap-img.com is in no way affiliated with SAP AG. Every effort is made to ensure the content integrity. Information used on this site is at your own risk. The content on this site may not be reproduced or redistributed without the express written permission of www.sap-img.com or the content authors.
http://www.sap-img.com/sapscripts/a-sample-sap-scripts-reports.htm (5 of 6) [4/10/2008 4:38:38 PM]

A Sample SAP Scripts Reports

http://www.sap-img.com/sapscripts/a-sample-sap-scripts-reports.htm (6 of 6) [4/10/2008 4:38:38 PM]