chapter 03_coding in the sapscript editor

25
IBM Global Services © 2005 IBM Corporation Coding in the SAPScript editor | 9.03 March-2005 Coding in the SAPScript editor

Upload: raul-thomas

Post on 19-Jan-2016

79 views

Category:

Documents


1 download

DESCRIPTION

Coding in the SAPScript Editor

TRANSCRIPT

Page 1: Chapter 03_Coding in the SAPScript Editor

IBM Global Services

© 2005 IBM CorporationCoding in the SAPScript editor | 9.03

March-2005

Coding in the SAPScript editor

Page 2: Chapter 03_Coding in the SAPScript Editor

IBM Global Services

© 2005 IBM Corporation2 March-2005Coding in the SAPScript editor | 9.03

Objectives

The participants will : Employ Text Elements in SAPScript forms.

Recognize SAPScript symbols.

Memorize SAPScript commands.

Execute Barcode Printing.

Print logo using SAPScript.

Page 3: Chapter 03_Coding in the SAPScript Editor

IBM Global Services

© 2005 IBM Corporation3 March-2005Coding in the SAPScript editor | 9.03

Text Elements

Text element always start with the line /E and continue to the next text element (/E). It is shown in red in the SAPScript editor.

It is the output program (not the layout set) that controls whether or not to print a text element (i.e. block of texts surrounded by /E) and the order in which they are printed.

Page 4: Chapter 03_Coding in the SAPScript Editor

IBM Global Services

© 2005 IBM Corporation4 March-2005Coding in the SAPScript editor | 9.03

Text Elements (Contd. )

To hard code text in SAPScripts, the texts to be displayed are written into the line of the editor. If the text to be displayed is continuous, use the ‘=‘ tag in the paragraph tag column.

To output SAP field values and variables, the field names and the variable names must be written with ampersands. For e.g. &KNA1-KUNNR& .

To use the tabs that have been defined in the paragraph formats the fields must have two commas per tab written between them. For e.g. &KNA1-KUNNR&,,&KNA1-NAME1&.

If there is a character format B which represents bold text , the format of using this is <B>any text </>. The character wrapper has two parts to it( <B> and </>) and both should be coded to make it work.

Page 5: Chapter 03_Coding in the SAPScript Editor

IBM Global Services

© 2005 IBM Corporation5 March-2005Coding in the SAPScript editor | 9.03

Symbols

Symbols are placeholders for values during print formatting.

Symbols are identified by a name which is included in ‘&’ characters. Example : &VBAK-VBELN&.

Depending on the source from which the value of a symbol comes from, they can be categorized as follows:

SYSTEM symbols

PROGRAM symbols

STANDARD symbols

TEXT symbols

Page 6: Chapter 03_Coding in the SAPScript Editor

IBM Global Services

© 2005 IBM Corporation6 March-2005Coding in the SAPScript editor | 9.03

Symbols (Contd.)

SYSTEM symbols are supplied by SAPScripts. They can be used in all texts. Following is a list of frequently used system symbols.

&DATE& = Current date, like ABAP field SY-DATUM

&DAY& = Day

&MONTH& = Month

&YEAR& = Year

&TIME& = Time of day , like ABAP field SY-UZEIT

&HOURS& = Hours

&MINUTES& = Minutes

&SECONDS& = Seconds

Page 7: Chapter 03_Coding in the SAPScript Editor

IBM Global Services

© 2005 IBM Corporation7 March-2005Coding in the SAPScript editor | 9.03

Symbols (Contd.)

Few more frequently used symbols: &PAGE& = Current Page Number

&NEXTPAGE& = Page no. of next page. It’s value is 0 for last page.

&SPACE& = Blanks

&ULINE& = Underline

&VLINE& = Vertical line

&NAME_OF_MONTH& = Name of month

&SAPSCRIPT-FORMPAGES& = Number of pages in the final document

Page 8: Chapter 03_Coding in the SAPScript Editor

IBM Global Services

© 2005 IBM Corporation8 March-2005Coding in the SAPScript editor | 9.03

Symbols (Contd.)

PROGRAM symbols are placeholders for values which come from the program that calls the SAPScript form. The symbol has to be defined in the Data Dictionary and filled with values by the output program.

Example:

in the layout set this will output the Customer’s name.

STANDARD symbol are maintained centrally in one table (TTDTG) for all SAPScript users.

Values of TEXT symbol are created by assignment via DEFINE statement. Example:

/: DEFINE &CASENUM& = ‘1234’.

&KNA1-NAME1&

Page 9: Chapter 03_Coding in the SAPScript Editor

IBM Global Services

© 2005 IBM Corporation9 March-2005Coding in the SAPScript editor | 9.03

Symbols (Contd.)

FORMATTING of the symbol can be done in following different ways: &SYMBOL+4& = Offset

&SYMBOL(5)& = Output Length

&SYMBOL(I)& = If the symbol is initial, output nothing

&SYMBOL(Z)& = Suppress leading zeros

&SYMBOL(C)& = Compress blanks

&SYMBOL(R)& = Right-justified output

&SYMBOL(S)& = Suppress leading +/- sign

&SYMBOL(5,2)& = Decimal place formatting

&SYMBOL(E3)& = Exponential notation

&’text1’SYMBOL’text2’& = Concatenation of symbol and text

Examples :

&VBDPR-MATNR+2(4)&

&VBDKL-BRGEW(I13)&

&’Currency : ’VBDKA-WAERK&

&’Case # &PREFIX&’VBDPR-BSTNK+2(8)’00’&

Page 10: Chapter 03_Coding in the SAPScript Editor

IBM Global Services

© 2005 IBM Corporation10 March-2005Coding in the SAPScript editor | 9.03

Commands

IF..ELSE..ENDIF can be used within the layout set to control the flow of logic. It is same as the corresponding ABAP command but with only one difference that no full stops are used here.

Example :

/: IF &VBRK-VKORG(2)& EQ ‘HG’ /: DEFINE &PREFIX& = ‘Mr.’ /: ELSE /: DEFINE &PREFIX& = ‘Mrs.’ /: ENDIF / &PREFIX&

Page 11: Chapter 03_Coding in the SAPScript Editor

IBM Global Services

© 2005 IBM Corporation11 March-2005Coding in the SAPScript editor | 9.03

Commands (Contd.)

CASE ..ENDCASE command can also be used in the layout set to control the flow of logic. It is same as the corresponding ABAP command but with only one difference that no full stops are used here.

Example :

/: CASE &VBDKL-VKORG(2)&/: WHEN ‘HG’/ Case # &‘934’VBDPL-SORTKRI&/: WHEN OTHERS/ Case # &‘999’VBDPL-SORTKRI&/: ENDCASE

Page 12: Chapter 03_Coding in the SAPScript Editor

IBM Global Services

© 2005 IBM Corporation12 March-2005Coding in the SAPScript editor | 9.03

Commands (Contd.)

Using the command NEW-PAGE, a page -break can be made in SAPScript at any position before the end of the page defined in the layout set. The next page can be specified explicitly.

Syntax:

A page break within a paragraph can be prevented by using this command PROTECT..ENDPROTECT.

Syntax :

The command DEFINE is used to assign a value to a text symbol. Syntax:

/: NEW-PAGE [PAGE]

/: PROTECT Any

text ……………… /:

ENDPROTECT

/: DEFINE &var_name& = ‘abcde’

Page 13: Chapter 03_Coding in the SAPScript Editor

IBM Global Services

© 2005 IBM Corporation13 March-2005Coding in the SAPScript editor | 9.03

Commands (Contd.)

The command ADDRESS…ENDADDRES formats an address according to the postal standards of the country of destination which is defined in the parameter COUNTRY.

Syntax :/: ADDRESS [DELIVERY] [TYPE t] [PARAGRAPH a][ PRIORITY p] [LINES l]/: TITLE form of address/: NAME name1[, name2[, name3[,name4]]]/: PERSON name of natural person [TITLE form of address]/: PERSONNUMBER number of the person/: DEPARTMENT department/: STREET strno HOUSE house number/: POBOX pobox [CODE code]/: POSTCODE postal code/: CITY city1[,city2]/: REGION district/: COUNTRY recipient country/: FORMCOUNTRY sender country/: ENDADDRESS

Page 14: Chapter 03_Coding in the SAPScript Editor

IBM Global Services

© 2005 IBM Corporation14 March-2005Coding in the SAPScript editor | 9.03

Commands (Contd.)

Parameter PRIORITY defines which address lines may be omitted, if necessary. The possible values are as follows :

A Form of address

B Mandatory blank line 1

C Mandatory blank line 2

2 Name2

3 Name3

4 Name4

L Country name

S Street line

O City line

The parameter LINES are available for formatting the address. Possible values are from 1 to n. If it is not possible to format all address data due to a lack of lines, the data which is entered in the parameter PRIORITY is omitted.

Page 15: Chapter 03_Coding in the SAPScript Editor

IBM Global Services

© 2005 IBM Corporation15 March-2005Coding in the SAPScript editor | 9.03

Commands (Contd.)

The date can be formatted using the command SET DATE MASK = ‘…’. After formatting all date fields are output as specified. The available formats for day, month and year are following.

DD Day

MM Month in figures

MMMM Month in words

YY Year (2 digits)

YYYY Year (4 digits)

Example :

The formatting can be reset at any point of time by /: SET DATE MASK = ‘’. Formatting is then carried out as defined by the System.

/: SET DATE MASK = ‘MM/DD/YYYY’

Page 16: Chapter 03_Coding in the SAPScript Editor

IBM Global Services

© 2005 IBM Corporation16 March-2005Coding in the SAPScript editor | 9.03

Commands (Contd.)

The time can be formatted using the command SET TIME MASK = ‘…’. After formatting all time fields are output as specified. The available formats for hours, minutes and seconds are following.

HH Hours

MM Minutes

SS Seconds

Example

The formatting can be reset at any point of time by /: SET TIME MASK = ‘’. Formatting is then carried out as defined by the System.

/: SET TIME MASK = ‘HH:MM:SS’

Page 17: Chapter 03_Coding in the SAPScript Editor

IBM Global Services

© 2005 IBM Corporation17 March-2005Coding in the SAPScript editor | 9.03

Commands (Contd.)

In SAPScript, any text can be included at a certain position in the document using INCLUDE command.

Syntax :

INCLUDE name OBJECT object ID identifier PARAGRAPH paragraph LANGUAGE language

Example :

There are two different types of text handled in SAPScript. One is APPLICATION TEXT and other one is STANDARD TEXT.

INCLUDE &VBDPL-TDNAME& OBJECT VBBP ID 0001 PARAGRAPH ITINCLUDE ‘SD_TEXT’ OBJECT TEXT ID SDVD PARAGRAPH HT

Page 18: Chapter 03_Coding in the SAPScript Editor

IBM Global Services

© 2005 IBM Corporation18 March-2005Coding in the SAPScript editor | 9.03

Commands (Contd.)

The ‘name’ in the include command is always the document no for APPLICATION TEXT and the name of standard text for STANDARD TEXT.

Example : vbdka-tdname, vbdkl-tdname, vbdkr-tdname.

The text ‘object’ specifies the environment to which a text belongs. TEXT NAME TEXT ORIGIN

VBBK Sales document Header Text

KNVV Customer Master SD Text

VBKA Contacts General Text

VTTK Shipment Header Text

The ‘object’ is always ‘TEXT’ for STANDARD TEXT.

Several different text IDs can belong to one object .

TEXT ID 0002 Sales document header note1.

0003 Sales document header note2.

Page 19: Chapter 03_Coding in the SAPScript Editor

IBM Global Services

© 2005 IBM Corporation19 March-2005Coding in the SAPScript editor | 9.03

Barcode Printing

To print barcode , follow the steps below : Select / Create a barcode font in SAP.

Create a character string and include the barcode with it.

The data need to printed as barcode should be attributed via the character string.

e.g./ <BC> * &VBAKA-WERKS& * </>

Page 20: Chapter 03_Coding in the SAPScript Editor

IBM Global Services

© 2005 IBM Corporation20 March-2005Coding in the SAPScript editor | 9.03

Logo Printing - Using Standard Text

To print a Logo, follow the steps below : Build a Logo. This file can be a bit map or windows meta file.

Convert the Logo to a TIF ( extension TIF ) file.

Use program RSTXLDMC to convert the TIF file to a standard text.

Print this standard text via SAPScript INCLUDE command. e.g.

/: INCLUDE ZHEX-IBMLOGO-PCL OBJECT TEXT ID ST

Page 21: Chapter 03_Coding in the SAPScript Editor

IBM Global Services

© 2005 IBM Corporation21 March-2005Coding in the SAPScript editor | 9.03

Logo Printing - Using GRAPHICS object

To print a logo using a GRAPHICS object (SAP 4.6B onwards) Build a Logo. This file can be a bit map.

Import the logo as a GRAPHICS object using transaction SE78 (Function key F5).

Print this GRAPHICS object via SAPScript INCLUDE command. e.g.

/: INCLUDE ZHEX-IBMLOGO-BMP OBJECT GRAPHICS ID BCOL

Page 22: Chapter 03_Coding in the SAPScript Editor

IBM Global Services

© 2005 IBM Corporation22 March-2005Coding in the SAPScript editor | 9.03

Demonstration

Changing the custom SAPScript created for the previous chapter using transaction SE71.

Creating a text-element in the main window to display the price of the ticket.

Displaying the date using SAPScript symbols

Formatting the date in MM/DD/YYYY format using SAPScript commands

Importing a logo for the airlines using transaction SE78 and displaying the same the same on the form.

Page 23: Chapter 03_Coding in the SAPScript Editor

IBM Global Services

© 2005 IBM Corporation23 March-2005Coding in the SAPScript editor | 9.03

Practice

Changing the custom SAPScript created for the previous chapter using transaction SE71.

Creating a text-element in the main window to display the price of the ticket.

Displaying the date using SAPScript symbols

Formatting the date in MM/DD/YYYY format using SAPScript commands

Importing a logo for the airlines using transaction SE78 and displaying the same the same on the form.

Page 24: Chapter 03_Coding in the SAPScript Editor

IBM Global Services

© 2005 IBM Corporation24 March-2005Coding in the SAPScript editor | 9.03

Summary

Text elements can be coded in the SAPScript editor. They always start with the line /E and continue to the next text element (/E).

SAPScript Symbols are placeholders for values during print formatting and are wrapped in in ‘&’ characters. Example : &VBAK-VBELN&.

Flow Logic commands e.g. CASE…ENDCASE and IF…ELSE…ENDIF can be used in layout sets to control the flow logic.

In SAPScript, any text can be included at a certain position in the document using INCLUDE command.

There are two different types of text handled in SAPScript. One is APPLICATION TEXT and other one is STANDARD TEXT.

Barcodes and Logos can be created in layout sets.

Page 25: Chapter 03_Coding in the SAPScript Editor

IBM Global Services

© 2005 IBM Corporation25 March-2005Coding in the SAPScript editor | 9.03

Questions

Is printing of the text elements on the form controlled by the layout set or the output program ?

What is the use of the ‘DEFINE’ command ?

What is the command for preventing a page break within a paragraph ?

What is the transaction executed to import a bitmap logo object as a graphics object in SAP R/3 ?

What is the use of the ‘INCUDE’ command in SAPScripts ?