sap scripts

63
ABAP Training SAP Script

Upload: kranthi-kumar

Post on 31-Oct-2014

340 views

Category:

Documents


3 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Sap scripts

ABAP Training

SAP Script

Page 2: Sap scripts

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.

Page 3: Sap scripts

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.

Page 4: Sap scripts

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.

Page 5: Sap scripts

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.

Page 6: Sap scripts

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

Page 7: Sap scripts

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

Page 8: Sap scripts

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.

Page 9: Sap scripts

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

Page 10: Sap scripts

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.

Page 11: Sap scripts

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

Page 12: Sap scripts

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

Page 13: Sap scripts

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.

Page 14: Sap scripts

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.

Page 15: Sap scripts

ABAP Training SAP Scripts 15

Form Painter (SE71)

Page 16: Sap scripts

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.

Page 17: Sap scripts

ABAP Training SAP Scripts 17

Header Details of Form

Page 18: Sap scripts

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.

Page 19: Sap scripts

ABAP Training SAP Scripts 19

Page Details - Form

Page 20: Sap scripts

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.

Page 21: Sap scripts

ABAP Training SAP Scripts 21

5. Next step is to create Windows on the Page .

Window Details - Form

Page 22: Sap scripts

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.

Page 23: Sap scripts

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.

Page 24: Sap scripts

ABAP Training SAP Scripts 24

Details of Page Windows

Page 25: Sap scripts

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.

Page 26: Sap scripts

ABAP Training SAP Scripts 26

Paragraph Formats - Form

Page 27: Sap scripts

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.

Page 28: Sap scripts

ABAP Training SAP Scripts 28

Character Format

Page 29: Sap scripts

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.

Page 30: Sap scripts

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.

Page 31: Sap scripts

ABAP Training SAP Scripts 31

MAIN Window – Text Element

Page 32: Sap scripts

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.

Page 33: Sap scripts

ABAP Training SAP Scripts 33

Header Details

Page 34: Sap scripts

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.

Page 35: Sap scripts

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.

Page 36: Sap scripts

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

Page 37: Sap scripts

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'

Page 38: Sap scripts

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]]]

Page 39: Sap scripts

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]

Page 40: Sap scripts

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

Page 41: Sap scripts

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

Page 42: Sap scripts

ABAP Training SAP Scripts 42

SE38 Program for Perform Stmt

Form <form_name> Tables itab like itcsy,

otab like itcsy.- - - - - - - - - - Coding

Endform

Page 43: Sap scripts

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

Page 44: Sap scripts

ABAP Training SAP Scripts 44

Case Command

Syntax : CASE command

/: CASE symbol /: WHEN value1

: /: WHEN valuen

: /: When others.

: /: ENDCASE

Page 45: Sap scripts

ABAP Training SAP Scripts 45

Protect – End Protect

Protect – EndProtect command is used to print complete text on same page.Syntax : / : PROTECT

- - - -- - - -

/ : ENDPROTECT

Page 46: Sap scripts

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.

Page 47: Sap scripts

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.

Page 48: Sap scripts

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.

Page 49: Sap scripts

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.

Page 50: Sap scripts

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)

Page 51: Sap scripts

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.

Page 52: Sap scripts

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.

Page 53: Sap scripts

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 .

Page 54: Sap scripts

ABAP Training SAP Scripts 54

Printing Company Logo Contd…..

Page 55: Sap scripts

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

Page 56: Sap scripts

ABAP Training SAP Scripts 56

Uploading Pictures

4. The TIFF file will be uploaded and gets stored as a text element in SO10.

Page 57: Sap scripts

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

Page 58: Sap scripts

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

Page 59: Sap scripts

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

Page 60: Sap scripts

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&

Page 61: Sap scripts

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) &

Page 62: Sap scripts

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

Page 63: Sap scripts

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.