on 09-08-2008 10:24 AM
Hello,
Plz explain me sap scripts with example.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
If you search the forum, you would find a number of links taking you to the basics of SAP Scripts. saptechnical.com is also a good site to search for tutorials on scripts.
Nayan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi nilam,
Script is the integrated text management system of SAP. The output of scripts and normal report will be same. But formatting is very easy using scripts. Usually scripts are used for external purpose and reports are used for internal purpose. When specific format is required in output we go for scripts.
In scripts we require layout set and print program. Layout set is used for designing the output. That is page designing is done here. For this Transaction code is SE71 (form painter).
Print program is used for writing the logic to get the data from data base. It is an executable program which is written in SE38 T-code.
Attributes of form painter (SE71)
1. Header
2. Pages
3. Windows
4. Page windows
5. Paragraph Formats
6. Character Formats
HEADER:- It contains Basic settings and administrative data. Administrative data gives history of the form and basic settings gives technical information about the form.
PAGES:- It is a logical memory area where output is formatted. It is a repository of pages.
WINDOWS:- I t is a place on the page where output or data is formatted. Page has to be divided into windows in order to hold the output. We canu2019t format the output outside the windows. Windows is repository of windows.
Paragraph formats and Character formats are used for alignment or beautifying the output.
TYPES OF WINDOWS
There are 3 types of windows.
1. Main window
2. Constant window
3. Variable window
MAIN WINDOW:- The window which can hold continuous text or which can call page break is called main windows. When ever you are not sure of how much data you are going to get into a window that window has to be created as main window.
CONSTANT WINDOW:- A window whose size and contents will not change from page to page is called Constant window.
VARIABLE WINDOW:- A window whose size or contents will change from page to page is called variable window.
Constant window and variable window can be used interchangingly.
Every script or layout should have at least one page. Every page should have at least one main window and paragraph format.
STEPS TO BE FOLLOWED IN CREATION OF LAYOUTSET ( PAGE)
1. T-code SE71
2. Give form name
3. Give language
4. Press create button
5. Give description
6. Press page button
7. Give page name
8. Press enter
9. Give page description
10. Give next page name
11. Press page windows button
12. To copy main window Edit -- Create element
13. Double click main window. ( main window will be copied to the page)
14. Give some window width and height (eg. 10 cm and 10 cm)
15. To see the page format Settings -- Form Painter
16. Check the check box Graphical Form Painter
17. Press enter
18. To adjust the main window , drag it to the place where you want. You can change the size also.
19. To create new windows right click create window.
20. Move the window to the position where it is needed and adjust the size.
21. To rename window Right click Rename.
22. To close page format Settings- Form painter
23. Un check the check box Graphical Form Painter
24. Press enter
25. To create paragraph format Press Paragraph formats push button
26. Give paragraph format name
27. Press enter
28. Give description
29. Press header
30. Press Basic settings
31. Give first page and Default paragraph
32. Save
33. To check errors form- check- Definition
34. To activate form - Activate.
This is how we have to design the page. The no of windows in the page depends on page layout. Now I want to keep a logo in one of the windows of page. For that we first have to upload the logo into sap. For uploading logo into sap the T-code is SE78.
It is used to upload only Bitmap images.
STEPS IN UPLOADING LOGO INTO SAP
1. Prepare a Bitmap Image
2. T-Code SE78
3. Expand graphics
4. Double click BMP.
5. Press import button
6. Give the path where image is present in you system
7. Give name to logo
8. Give description
9. Specify color image or Black and white imageu2019
10. Press enter
The image will be uploaded into SAP with the name you have given in 7th step.
If the image is of .TIF format we have to run the standard program RSTXLDMC to upload the image into SAP. The image will be stored on document server. All the images will be stored in STXBITMAPS table.
Now my requirement is to insert the logo in one of the windows of the form that I have designed .
STEPS IN INSERTING THE LOGO IN A PARTICULAR WINDOW
1. Go to Se71
2. Open the form in change mode
3. Select the window where you need to insert the logo ( for selecting double click)
4. Press text elements button
5. Insert Graphics
6. Press tab stored on document server
7. Give the logo name
8. Choose Black and white or color
9. Enter
10. System by default gives this code
11. BITMAP 'ENJOY' OBJECT GRAPHICS ID BMAP TYPE BCOL
12. Here enjoy is the logo name I have given
Now we will discuss how to write the print program. Print program is used to get the data from data base and move the page windows of the form. In writing the print program we have to take the help of 3 function modules.
1. OPEN_FORM:- This function module is used to open a layout set printing.
2. WRITE_FORM:- This function module is used to move the data from print program to page windows. The movement of data is done using element.
3. CLOSE_FORM:- This function module is used to close the layout set printing. If this is not used there will be no output and no printout.
The sample program is as follows.
REPORT ZFORM .
TABLES MARA.
SELECT-OPTIONS S_MATNR FOR MARA-MATNR.
DATA: BEGIN OF ITAB OCCURS 0,
MATNR TYPE MARA-MATNR,
MBRSH TYPE MARA-MBRSH,
MTART TYPE MARA-MTART,
NTGEW TYPE MARA-NTGEW,
BRGEW TYPE MARA-BRGEW,
END OF ITAB.
SELECT MATNR
MBRSH
MTART
NTGEW
BRGEW FROM MARA
INTO TABLE ITAB
WHERE MATNR IN S_MATNR.
CALL FUNCTION 'OPEN_FORM'
EXPORTING
APPLICATION = 'TX'
ARCHIVE_INDEX =
ARCHIVE_PARAMS =
DEVICE = 'PRINTER'
DIALOG = 'X'
FORM = 'ZFORM10'
LANGUAGE = SY-LANGU
OPTIONS =
MAIL_SENDER =
MAIL_RECIPIENT =
MAIL_APPL_OBJECT =
RAW_DATA_INTERFACE = '*'
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.
LOOP AT ITAB.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'ELE'
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
CODEPAGE = 9
OTHERS = 10
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDLOOP.
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
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
In the above program I have used element in write_form function module. When we are moving the data into form windows there should be something to receive it. We are sending using element ELE.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.