sap scripts
DESCRIPTION
TRANSCRIPT
ABAP Training
SAP Script
ABAP Training SAP Scripts 2
What Is SAP Script ?
SAP script is the SAP system's own text-processing system. SAP script is integrated text management system of the SAP R/3 system. The transaction code is SE71.
ABAP Training SAP Scripts 3
Why SAP Script ?
It is used to print preformatted text in preformatted forms. Unlike reports , the text can be aligned, different fonts can be
used.Company logo can be printed.
ABAP Training SAP Scripts 4
How to Go About Creating Forms ?
A layout set is defined as a page design for a document. A layout set specifies the page design by defining one or more windows
and arranging them on a page. Layout set on its own does not contain any data.
ABAP Training SAP Scripts 5
Creating Forms Contnd……
The selection of data for the document is done through the print program.
The print program selects the data from database table and feeds it to the layout set.
When the print program is executed the document is printed.
ABAP Training SAP Scripts 6
Components of Layout Set
A layout set consists of following components
Header Pages Windows Page windows Paragraph formats Character formats
ABAP Training SAP Scripts 7
Header
Header – this part of the layout set consists of both administrative data and basic (default) settings for the various other components of the layout set like first page, default paragraph for layout set etc.,
Header data : used for information and control purposes.- Start page- Default paragraph- Tab stop- Language, original language- Page format- Orientation- Lines per inch (LPI)- Characters per inch (CPI)- Font attributes
ABAP Training SAP Scripts 8
Pages
Pages :Must define at least one page for every form and you must designate aFirst page in the form header.Page attributes :
- Next page - Page counter mode- Resource name ( paper tray to be used for printer)- Paper mode (simplex , Tumblex)
Page windows :Window names are linked to page names and specify the window Position on the page.
Text elements :The print program accesses text elements by name, formats them andPrints them in the respective window.
ABAP Training SAP Scripts 9
Windows
Windows – at least one logical window must be defined for every page. (Otherwise it is not possible to format the texts) window definition involves a list of window names and corresponding window types. A MAIN window is displayed automatically. They represent areas that are positioned on pages as page windows and in which at a later time text is printed.
Window types :- Main- Var- Const
ABAP Training SAP Scripts 10
Page Windows
Page windows - A page window is defined by allocating a logical window to a logical page and specifying the position and size of the window.
ABAP Training SAP Scripts 11
Paragraph Formats
Paragraph formats – A paragraph contains all the information needed to format a paragraph of text and font. Tabs are important for paragraphs. Specifying the list of tabs is the way to create columns for outputting line items of a document.
Paragraph formats and attributes :- Standard- Font- Tabs- Outline
ABAP Training SAP Scripts 12
Character Formats
Character formats – this is used to override paragraph settings for specific words in a paragraph.
Character formats and attributes :- Standard- Font
ABAP Training SAP Scripts 13
Creating a Layout Set
To create a layout set go to tools -> SAP script -> form. The transaction code is SE71.
ABAP Training SAP Scripts 14
Steps to Create Layout Set
1. Go to SE71. This takes you to the form .Enter name for the layout / form in the text box given.The screen as shown below.
ABAP Training SAP Scripts 15
Form Painter (SE71)
ABAP Training SAP Scripts 16
Steps to Create Layout Set Contd….
2. After entering the name for the layout set choose the “create” button.This takes you to the next screen where in you need to enter the description for the layout set.
ABAP Training SAP Scripts 17
Header Details of Form
ABAP Training SAP Scripts 18
Steps to Create Layout Set Contd….
3. Next step is to create pages for the layout or form.Go to pages button on the application toolbar.Enter name for the page in the standard attributes and description for the page.For the next page in the standard attribute specify the name.
ABAP Training SAP Scripts 19
Page Details - Form
ABAP Training SAP Scripts 20
Steps to Create Layout Set Contd….
4. The above screen takes to the pages screen of the form.After pages, you have to create windows needed for the page.Go to windows button on the toolbar.MAIN window is created given by the system itself.The window can be of type VAR or CONST except for MAIN.
ABAP Training SAP Scripts 21
5. Next step is to create Windows on the Page .
Window Details - Form
ABAP Training SAP Scripts 22
Steps to Create Layout Set Contd….
6. To create windows go to edit -> create element of menu bar.Using this option you can create as many windows as needed for the page.By default the window created will have window type as VAR.For windows to be constant, you can name them as CONST.
ABAP Training SAP Scripts 23
Steps to Create Layout Set Contd….
7. Next step after creating windows is to “create page windows”.Click “page windows” on the application toolbar. Choose the windows needed for that page using edit -> create element. Enter the margins for the page windows created in the standard attributes.
ABAP Training SAP Scripts 24
Details of Page Windows
ABAP Training SAP Scripts 25
Paragraph Formats
8. Go to paragraph formats in the application toolbar.9. Name the paragraph format and enter the description .Specify the font
family and size .If needed ,specify the tab positions. Tabs are columns created for outputting line items of a document.
ABAP Training SAP Scripts 26
Paragraph Formats - Form
ABAP Training SAP Scripts 27
Character Formats
10. Next step is to create “character formats”.This is used to override the paragraph settings for specific words.
ABAP Training SAP Scripts 28
Character Format
ABAP Training SAP Scripts 29
Steps to Create Layout Set Contd….
11. Go to text elements (F9) in the application toolbar of the selected page window.
12. The text elements are assigned to the active window. You can create several text elements in a window.
ABAP Training SAP Scripts 30
Steps to Create Layout Set Contd….
13. The text elements are called from print program,through function modules and outputted in the respective window.
ABAP Training SAP Scripts 31
MAIN Window – Text Element
ABAP Training SAP Scripts 32
Steps to Create Layout Set Contd….
14. Next step is to save the layout.Go to form -> save. While saving the form ,it asks for the default paragraph and page in header details of basic settings.You need to specify the default paragraph and page in this page.
ABAP Training SAP Scripts 33
Header Details
ABAP Training SAP Scripts 34
Steps to Create Layout Set Contd….
16. The form gets saved after entering the above details. Save the form and activate the layout set.After activating the form,a driver program or print program has to written or modified according to the requirement in SE38.
ABAP Training SAP Scripts 35
SAP Script – Control Commands
New page : forcing a page break in a text.
Syntax : /: NEW-PAGE [page_name]
Ex : /: NEW-PAGE S1 -> contents of S1 are printed in a new page.
ABAP Training SAP Scripts 36
Date Command
Set date mask : formatting date fields.Syntax :
/: SET DATE MASK = ‘date_mask’.Ex : /: SET DATE MASK = ‘DD/MM/YY’.
&Date& = 01/01/01
ABAP Training SAP Scripts 37
Include Command
3. INCLUDE : to include contents of another text into current text.Syntax : /: INCLUDE name [OBJECT o] [ID i] [LANGUAGE l]
[PARAGRAPH p] [NEW-PARAGRAPH np]Ex :
/: Include MYTEXT language 'e' paragraph 'a1'
ABAP Training SAP Scripts 38
Address – EndAddress
ADDRESS – ENDADDRESS : to format the address.Syntax :/: ADDRESS [DELIVERY] [TYPE t] [PARAGRAPH a] [PRIORITY p] [LINES l] /: TITLE title /: NAME name1[,name2[,name3[,name4]]]
ABAP Training SAP Scripts 39
Address – EndAddress Contnd…..
/: PERSON name of natural person [TITLE form of address]/: DEPARTMENT department/: STREET street name /: LOCATION additional location information/: POBOX po box [CODE post code / zip code] [CITY city]
ABAP Training SAP Scripts 40
Address – EndAddress Contnd…..
/: POSTCODE post code / zip_code /: CITY city1[,city2] /: REGION county / state /: COUNTRY recipient country [LANGUAGE language code]/: FROMCOUNTRY sender country /: ADDRESSNUMBER address number/: ENDADDRESS
ABAP Training SAP Scripts 41
Perform Command
5. PERFORM : it is used to call an ABAP/4 subroutine from any SE38 program.
Syntax : /: PERFORM <form_name> IN PROGRAM <prog>/: Using &invar1&…../: Changing &outvar1&…../: ENDPERFORM
ABAP Training SAP Scripts 42
SE38 Program for Perform Stmt
Form <form_name> Tables itab like itcsy,
otab like itcsy.- - - - - - - - - - Coding
Endform
ABAP Training SAP Scripts 43
IF Command
6. /: IF condition :
/: ENDIF = EQ equal to < LT less than > GT greater than <= LE less than or equal to >= GE greater than or equal to <> NE not equal to
ABAP Training SAP Scripts 44
Case Command
Syntax : CASE command
/: CASE symbol /: WHEN value1
: /: WHEN valuen
: /: When others.
: /: ENDCASE
ABAP Training SAP Scripts 45
Protect – End Protect
Protect – EndProtect command is used to print complete text on same page.Syntax : / : PROTECT
- - - -- - - -
/ : ENDPROTECT
ABAP Training SAP Scripts 46
Driver Program
The execution of script is done through driver program The driver program can be either a stand alone program or it can be
called from any transaction.
ABAP Training SAP Scripts 47
Driver Program Cont. ….
In the 2nd case for execution of script go to the reqd. Transaction and reqd. Document no. For which the print out or fax to be taken and enter the output type, transmission medium and the partner to whom we have to send.
For a standard configuration we can see the form name, program name and output type in the table TNAPR.
ABAP Training SAP Scripts 48
Driver Program Cont ….
Other details like mode of print, I.E. Print immediately or scheduling of jobs also can be entered in the transaction itself.
If the mode of print is set as print immediately, then the script is executed as soon as the user saves the transaction.
In later case one has to run the program RSNAST00 to get the output.
ABAP Training SAP Scripts 49
Driver Program Cont ….
All the details entered in the transaction will be stored in the table NAST.
So without an entry in the NAST table execution of script is not possible through RSNAST00.
For standalone driver programs entry in NAST is not required and the form name and driver program name may not appear in the TNAPR table.
ABAP Training SAP Scripts 50
Function Modules
The driver program must contain either all or some of the function modules listed below.
Open_form (mandatory) Start_form (optional) Write_form (mandatory) End_form (optional) Close_form (mandatory)
ABAP Training SAP Scripts 51
….Cont
If start_form is present then end_form also should be there. One more function module which is useful is control_form. This is also
optional.
ABAP Training SAP Scripts 52
Translation of Layout Set
To create layout set in different languages use transaction SE63. The complete path from SE63 is translation long texts SAP scripts forms (SE76).
Enter the form name, source language and target language.
ABAP Training SAP Scripts 53
Printing Company Logo
Steps required to print a company logo :1. Go to SE38 .Type RSTXLDMC in the text box provided .
ABAP Training SAP Scripts 54
Printing Company Logo Contd…..
ABAP Training SAP Scripts 55
Printing Company Logo Contd…..
2. Execute the program by pressing F8.3. Enter the file name of the TIFF file,resolution ,text name and text title
ABAP Training SAP Scripts 56
Uploading Pictures
4. The TIFF file will be uploaded and gets stored as a text element in SO10.
ABAP Training SAP Scripts 57
Different Commands in SAP Script
BOX :- command for drawing a box or a horizontal or vertical line./: Box [XPOS] [YPOS] [width] [height] [frame] [intensity]
POSITION :- command for specifying the width and the height of the box
/: Position [XORIGIN] [YORIGIN] [window] [page]
SIZE :- sets the values of the WIDTH and HEIGHT parameters used in
The BOX command/: Size [width] [height] [window] [page]
Syntax of control commands :-Use the paragraph format /:
Does not occupy more than a single line
ABAP Training SAP Scripts 58
Different Commands in SAP Script Contd….
Explicit page break :- NEW-PAGE/: New-page [page_name]
Preventing page breaks :- PROTECT/: Protect
::
/: ENDPROTECT
Assigning value to a text symbol :- DEFINE/: DEFINE &symbol_name& = ‘value’
Conditional text :-/: IF condition
:/: Else
:/: ENDIF
ABAP Training SAP Scripts 59
Different Commands in SAP Script Contd….
Formatting :-
/: SET DATE MASK = ‘date_mask’eg. /: Set date mask ‘mm/DD/YY’
&Date& -> 06/06/02
/: SET TIME MASK = ‘time_mask’eg. /: Set time mask ‘HH:mm’
&Time& -> 11:52
/: Set sign left
/: Set sign right
ABAP Training SAP Scripts 60
Different Commands in SAP Script Contd….
Setting header text in main window :-/: Top
::
/: ENDTOP
Setting footer text in main window :-/: Bottom
::
/: ENDBOTTOM
General SAPSCRIPT fields :&SAPSCRIPT-SUBRC&&SAPSCRIPT-FORMPAGES&&Page&&Date&&ULINE&
ABAP Training SAP Scripts 61
Different Commands in SAP Script Contd….
Formatting options :Offset
&Symbol& -> 123456789&Symbol+3& -> 456789
Output length&Symbol( length )&
Omitting the leading sign&Symbol(s)&
Leading sign to left&Symbol(<)&
Omitting leading zeros&Symbol(z)&
Space compression&Symbol(c) &
ABAP Training SAP Scripts 62
Different Commands in SAP Script Contd….Number of decimal places
&Symbol(.N)&
Omitting the separator for ‘thousands ‘&Symbol(t)&
Suppressing output of initial values&Symbol(i)&
Function modules in print program Open_form Close_form Start_form End_form Write_form Control_form
ABAP Training SAP Scripts 63
Utilities and Programs
RSTXCRP :- program is used to upload and download a form across
different system using the local file system as an interface.
Utilities copy from client is used to copy the layout in the same System across different clients.
Form >> copy from to copy in the other language
Utilities >> change page format
Table TNAPR – what program is attached to which layout.