TABLES : ZPACK,ZTRN.
DATA: BEGIN OF ITAB OCCURS 0, ZPKSLIP_NO LIKE ZTRN-ZPKSLIP_NO, ZCARTON_NO LIKE ZPACK-ZCARTON_NO, END OF ITAB.
DATA MVAR(12) TYPE C. DATA MCTR(6) TYPE C.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001. SELECT-OPTIONS: ZSLIP FOR ZTRN-ZPKSLIP_NO NO-EXTENSION NO INTERVALS OBLIGATORY default 6. SELECTION-SCREEN END OF BLOCK B1.
SELECT * FROM ZPACK INTO CORRESPONDING FIELDS OF TABLE ITAB WHERE ZPKSLIP_NO EQ ZSLIP-LOW .
CALL FUNCTION 'OPEN_FORM' EXPORTING FORM = 'ZTEST_RAJ'.
DO 4 TIMES.
MCTR = 100000 + SY-INDEX. MCTR = MCTR+1(5). CONCATENATE '55C/06/' MCTR INTO MVAR.
DO 80 TIMES. ITAB-ZPKSLIP_NO = MVAR. ITAB-ZCARTON_NO = SY-INDEX. APPEND ITAB. CLEAR ITAB. ENDDO.
ENDDO.
SORT ITAB BY ZPKSLIP_NO ZCARTON_NO.
CALL FUNCTION 'START_FORM' EXPORTING FORM = 'ZTEST_RAJ'.
LOOP AT ITAB.
AT NEW ZPKSLIP_NO.
CALL FUNCTION 'WRITE_FORM' EXPORTING ELEMENT = '101' WINDOW = 'MAIN'.
ENDAT.
CALL FUNCTION 'WRITE_FORM' EXPORTING ELEMENT = '102' WINDOW = 'MAIN'.
AT END OF ZPKSLIP_NO.
CALL FUNCTION 'END_FORM'.
CALL FUNCTION 'START_FORM' EXPORTING FORM = 'ZTEST_RAJ'.
ENDAT.
ENDLOOP.
CALL FUNCTION 'END_FORM'.
CALL FUNCTION 'CLOSE_FORM'.
In sap script write : /E 101 P1 ,,&ITAB-ZPKSLIP_NO(R)& P1 /E 102 P1 ,,&ITAB-ZCARTON_NO(R)&
Sap Script
SAP Script Code and Documentaion
Thursday, May 3, 2007
A Sample SAP Scripts Reports
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.
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 = 'SET'
* TYPE = 'BODY'
WINDOW = 'HEADER'
* IMPORTING
* PENDING_LINES =
EXCEPTIONS
ELEMENT = 1
FUNCTION = 2
TYPE = 3
UNOPENED = 4
UNSTARTED = 5
WINDOW = 6
BAD_PAGEFORMAT_FOR_PRINT = 7
SPOOL_ERROR = 8
OTHERS = 9
.
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 = 'SET'
* TYPE = 'BODY'
WINDOW = 'MAIN'
* IMPORTING
* PENDING_LINES =
EXCEPTIONS
ELEMENT = 1
FUNCTION = 2
TYPE = 3
UNOPENED = 4
UNSTARTED = 5
WINDOW = 6
BAD_PAGEFORMAT_FOR_PRINT = 7
SPOOL_ERROR = 8
OTHERS = 9
.
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 = 'SET'
* TYPE = 'BODY'
WINDOW = 'FOOTER'
* IMPORTING
* PENDING_LINES =
EXCEPTIONS
ELEMENT = 1
FUNCTION = 2
TYPE = 3
UNOPENED = 4
UNSTARTED = 5
WINDOW = 6
BAD_PAGEFORMAT_FOR_PRINT = 7
SPOOL_ERROR = 8
OTHERS = 9
.
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 'END_FORM'
* IMPORTING
* RESULT =
* EXCEPTIONS
* UNOPENED = 1
* BAD_PAGEFORMAT_FOR_PRINT = 2
* SPOOL_ERROR = 3
* CODEPAGE = 4
* OTHERS = 5
.
CALL FUNCTION 'CLOSE_FORM'
* IMPORTING
* RESULT =
* RDI_RESULT =
* TABLES
* OTFDATA =
* EXCEPTIONS
* UNOPENED = 1
* BAD_PAGEFORMAT_FOR_PRINT = 2
* SEND_ERROR = 3
* SPOOL_ERROR = 4
* CODEPAGE = 5
* OTHERS = 6
.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.
* 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.
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 = 'SET'
* TYPE = 'BODY'
WINDOW = 'HEADER'
* IMPORTING
* PENDING_LINES =
EXCEPTIONS
ELEMENT = 1
FUNCTION = 2
TYPE = 3
UNOPENED = 4
UNSTARTED = 5
WINDOW = 6
BAD_PAGEFORMAT_FOR_PRINT = 7
SPOOL_ERROR = 8
OTHERS = 9
.
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 = 'SET'
* TYPE = 'BODY'
WINDOW = 'MAIN'
* IMPORTING
* PENDING_LINES =
EXCEPTIONS
ELEMENT = 1
FUNCTION = 2
TYPE = 3
UNOPENED = 4
UNSTARTED = 5
WINDOW = 6
BAD_PAGEFORMAT_FOR_PRINT = 7
SPOOL_ERROR = 8
OTHERS = 9
.
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 = 'SET'
* TYPE = 'BODY'
WINDOW = 'FOOTER'
* IMPORTING
* PENDING_LINES =
EXCEPTIONS
ELEMENT = 1
FUNCTION = 2
TYPE = 3
UNOPENED = 4
UNSTARTED = 5
WINDOW = 6
BAD_PAGEFORMAT_FOR_PRINT = 7
SPOOL_ERROR = 8
OTHERS = 9
.
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 'END_FORM'
* IMPORTING
* RESULT =
* EXCEPTIONS
* UNOPENED = 1
* BAD_PAGEFORMAT_FOR_PRINT = 2
* SPOOL_ERROR = 3
* CODEPAGE = 4
* OTHERS = 5
.
CALL FUNCTION 'CLOSE_FORM'
* IMPORTING
* RESULT =
* RDI_RESULT =
* TABLES
* OTFDATA =
* EXCEPTIONS
* UNOPENED = 1
* BAD_PAGEFORMAT_FOR_PRINT = 2
* SEND_ERROR = 3
* SPOOL_ERROR = 4
* CODEPAGE = 5
* OTHERS = 6
.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.
FAQ for Sap Scripts
What is the difference between a script & a report ?
Script is a form which has a layout set as per the company standards and can be used for external use too. Generally reports are designed for internal use for in house users
What are the components/elements in sap script ?
Layout set and Print program and the layout set has windows in it.
Can you create a script with out a main window ?
No
How many main windows can be created for a script ?
99
How can we use tables in sap scripts?
We can access structures and the tables tat are updated during runtime. Else you have to pass the structure values to the table in the print program.
How to print a logo in a sap script?
Upolad in the R3 using Se78 and use the Include statement in the script.
When we need to modify standard scripts (eg:medruck) given by sap?
When the client goes for customization of the form
What is the use of transaction code NACE in sap scripts?
You can track the form and the print program used for that form
What is the table name that will contain all the script form names and print program names?
TNAPR
Can you assign your own form to a standard print program? how?
Yes. thru NACE
What is the use of PROTECT & ENDPROTECT?
Keeps the block of text in the same page.
How to add extra functionality to a standard print program with out touching the print program? Thru subroutine programs
What is sub routine pool in sap script?
when it is used?
Its an Abap prog of type sub routine pool, it is used for calculating certain variables, eg DUE date for an Invoice. You pass the values from the form thru ITCSY structure intot he prgram.
How to read text in sapscripts?
SO10
What is the difference between paragraph & character format?
Self explanatory definition
How to use a sapscript for multiple languages ?
(english, germany etc) Copy the script in each lang or you have an option to click 'TO all Languages'
How to download/upload sapscripts from & to your PC ?
SE78 or RSTXLDMC
What is the difference between scripts & smart forms?
Scripts are client-dependent but SF are client Independent
Sapscripts and abap programs are client dependent or not? Why?
Scripts are client dependent. / Reports are client Independent.
What is the transaction code for logo uploading?
SE78
What is the standard program used for uploading the logo to script?
RSTXLDMC FM to upload image in tiff format.
How can you send forms from one client to other?
SE71, Utilities -> Copy from client...
What does open_form, write_form, close_form do?
Again its self-explanatory
What is the diffrence between open_form and close_form?
open_form is used to open the form/initiate the form. close_form is used to conclude the open_form.
How to convert a sapscript to smart form?
tcode SMARTFORMS, I think its menu Utilities you have an option.. Migrate Scripts to Smartforms.
How to send a smartform result through mail?
I think you have to configure the output type. Not sure..
How to select desired paper size in sapscript?
In Basic settings.
How to print the Page Nos in Forms. Every page I want to print 1 of 10 , 2 of 10 , 3 of 0 ...etc. PAGE &PAGE& OF &SAPSCRIPT-FORMPAGES&
How to debugg a script?
This can done in two ways: In the form Utilities->debugger / RSTXDBUG FM for debugging script
The Procedure for debugging SAP script is: Generally SAP script contains the Layout and corresponding print program. First go to SE71 and enter ur script name. In the same screen go to Utilities->click on activate debugger option. Now go to SE 38 and enter ur Print Program name and execute the program. Now you can debug the script Page wise and window wise.
Script is a form which has a layout set as per the company standards and can be used for external use too. Generally reports are designed for internal use for in house users
What are the components/elements in sap script ?
Layout set and Print program and the layout set has windows in it.
Can you create a script with out a main window ?
No
How many main windows can be created for a script ?
99
How can we use tables in sap scripts?
We can access structures and the tables tat are updated during runtime. Else you have to pass the structure values to the table in the print program.
How to print a logo in a sap script?
Upolad in the R3 using Se78 and use the Include statement in the script.
When we need to modify standard scripts (eg:medruck) given by sap?
When the client goes for customization of the form
What is the use of transaction code NACE in sap scripts?
You can track the form and the print program used for that form
What is the table name that will contain all the script form names and print program names?
TNAPR
Can you assign your own form to a standard print program? how?
Yes. thru NACE
What is the use of PROTECT & ENDPROTECT?
Keeps the block of text in the same page.
How to add extra functionality to a standard print program with out touching the print program? Thru subroutine programs
What is sub routine pool in sap script?
when it is used?
Its an Abap prog of type sub routine pool, it is used for calculating certain variables, eg DUE date for an Invoice. You pass the values from the form thru ITCSY structure intot he prgram.
How to read text in sapscripts?
SO10
What is the difference between paragraph & character format?
Self explanatory definition
How to use a sapscript for multiple languages ?
(english, germany etc) Copy the script in each lang or you have an option to click 'TO all Languages'
How to download/upload sapscripts from & to your PC ?
SE78 or RSTXLDMC
What is the difference between scripts & smart forms?
Scripts are client-dependent but SF are client Independent
Sapscripts and abap programs are client dependent or not? Why?
Scripts are client dependent. / Reports are client Independent.
What is the transaction code for logo uploading?
SE78
What is the standard program used for uploading the logo to script?
RSTXLDMC FM to upload image in tiff format.
How can you send forms from one client to other?
SE71, Utilities -> Copy from client...
What does open_form, write_form, close_form do?
Again its self-explanatory
What is the diffrence between open_form and close_form?
open_form is used to open the form/initiate the form. close_form is used to conclude the open_form.
How to convert a sapscript to smart form?
tcode SMARTFORMS, I think its menu Utilities you have an option.. Migrate Scripts to Smartforms.
How to send a smartform result through mail?
I think you have to configure the output type. Not sure..
How to select desired paper size in sapscript?
In Basic settings.
How to print the Page Nos in Forms. Every page I want to print 1 of 10 , 2 of 10 , 3 of 0 ...etc. PAGE &PAGE& OF &SAPSCRIPT-FORMPAGES&
How to debugg a script?
This can done in two ways: In the form Utilities->debugger / RSTXDBUG FM for debugging script
The Procedure for debugging SAP script is: Generally SAP script contains the Layout and corresponding print program. First go to SE71 and enter ur script name. In the same screen go to Utilities->click on activate debugger option. Now go to SE 38 and enter ur Print Program name and execute the program. Now you can debug the script Page wise and window wise.
Subscribe to:
Posts (Atom)