You are on page 1of 25

IBM Global Services

Coding in the SAPScript editor

Coding in the SAPScript editor | Dec-2008 © 2005 IBM Corporation


IBM Global Services

Objectives

 The participants will :


 Employ Text Elements in SAPScript forms.
 Recognize SAPScript symbols.
 Memorize SAPScript commands.
 Execute Barcode Printing.
 Print logo using SAPScript.

2 Coding in the SAPScript editor | Dec-2008 © 2005 IBM Corporation


IBM Global Services

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.

3 Coding in the SAPScript editor | Dec-2008 © 2005 IBM Corporation


IBM Global Services

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.

4 Coding in the SAPScript editor | Dec-2008 © 2005 IBM Corporation


IBM Global Services

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

5 Coding in the SAPScript editor | Dec-2008 © 2005 IBM Corporation


IBM Global Services

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

6 Coding in the SAPScript editor | Dec-2008 © 2005 IBM Corporation


IBM Global Services

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

7 Coding in the SAPScript editor | Dec-2008 © 2005 IBM Corporation


IBM Global Services

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:

&KNA1-NAME1&
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’.

8 Coding in the SAPScript editor | Dec-2008 © 2005 IBM Corporation


IBM Global Services

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

9 Coding in the SAPScript editor | Dec-2008 © 2005 IBM Corporation


IBM Global Services

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&

10 Coding in the SAPScript editor | Dec-2008 © 2005 IBM Corporation


IBM Global Services

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

11 Coding in the SAPScript editor | Dec-2008 © 2005 IBM Corporation


IBM Global Services

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:

/: NEW-PAGE [PAGE]

 A page break within a paragraph can be prevented by using this command


PROTECT..ENDPROTECT.
 Syntax :
/: PROTECT
Any text ………………
/:
ENDPROTECT

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


 Syntax:

/: DEFINE &var_name& = ‘abcde’

12 Coding in the SAPScript editor | Dec-2008 © 2005 IBM Corporation


IBM Global Services

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
13 Coding in the SAPScript editor | Dec-2008 © 2005 IBM Corporation
IBM Global Services

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.

14 Coding in the SAPScript editor | Dec-2008 © 2005 IBM Corporation


IBM Global Services

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 : /: SET DATE MASK = ‘MM/DD/YYYY’
 The formatting can be reset at any point of time by
 /: SET DATE MASK = ‘’. Formatting is then carried out as defined by the System.

15 Coding in the SAPScript editor | Dec-2008 © 2005 IBM Corporation


IBM Global Services

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 /: SET TIME MASK = ‘HH:MM:SS’
 The formatting can be reset at any point of time by
 /: SET TIME MASK = ‘’. Formatting is then carried out as defined by the System.

16 Coding in the SAPScript editor | Dec-2008 © 2005 IBM Corporation


IBM Global Services

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 :

INCLUDE &VBDPL-TDNAME& OBJECT VBBP ID 0001 PARAGRAPH IT


INCLUDE ‘SD_TEXT’ OBJECT TEXT ID SDVD PARAGRAPH HT

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

17 Coding in the SAPScript editor | Dec-2008 © 2005 IBM Corporation


IBM Global Services

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.

18 Coding in the SAPScript editor | Dec-2008 © 2005 IBM Corporation


IBM Global Services

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& * </>

19 Coding in the SAPScript editor | Dec-2008 © 2005 IBM Corporation


IBM Global Services

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

20 Coding in the SAPScript editor | Dec-2008 © 2005 IBM Corporation


IBM Global Services

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

21 Coding in the SAPScript editor | Dec-2008 © 2005 IBM Corporation


IBM Global Services

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.

22 Coding in the SAPScript editor | Dec-2008 © 2005 IBM Corporation


IBM Global Services

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.

23 Coding in the SAPScript editor | Dec-2008 © 2005 IBM Corporation


IBM Global Services

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.

24 Coding in the SAPScript editor | Dec-2008 © 2005 IBM Corporation


IBM Global Services

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 ?

25 Coding in the SAPScript editor | Dec-2008 © 2005 IBM Corporation

You might also like