Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
128 views

Chapter 03 - Coding in The SAPScript Editor

The document discusses coding in the SAPScript editor. It covers topics like text elements, symbols, commands used in SAPScript like IF/ELSE, CASE, and formatting dates and addresses. Examples are provided for most coding constructs discussed.

Uploaded by

Raul Thomas
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
128 views

Chapter 03 - Coding in The SAPScript Editor

The document discusses coding in the SAPScript editor. It covers topics like text elements, symbols, commands used in SAPScript like IF/ELSE, CASE, and formatting dates and addresses. Examples are provided for most coding constructs discussed.

Uploaded by

Raul Thomas
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 25

IBM Global Services

2005 IBM Corporation Coding in the SAPScript editor |


9.03
March-2005
Coding in the SAPScript editor
IBM Global Services
2005 IBM Corporation 2 March-2005 Coding 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.

IBM Global Services
2005 IBM Corporation 3 March-2005 Coding 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.

IBM Global Services
2005 IBM Corporation 4 March-2005 Coding 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.

IBM Global Services
2005 IBM Corporation 5 March-2005 Coding 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

IBM Global Services
2005 IBM Corporation 6 March-2005 Coding 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


IBM Global Services
2005 IBM Corporation 7 March-2005 Coding in the SAPScript editor | 9.03
Symbols (Contd.)
Few more frequently used symbols:
&PAGE& = Current Page Number
&NEXTPAGE& = Page no. of next page. Its 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

IBM Global Services
2005 IBM Corporation 8 March-2005 Coding 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 Customers 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&
IBM Global Services
2005 IBM Corporation 9 March-2005 Coding 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
&text1SYMBOLtext2& = Concatenation of symbol and text
Examples :
&VBDPR-MATNR+2(4)&
&VBDKL-BRGEW(I13)&
&Currency : VBDKA-WAERK&
&Case # &PREFIX&VBDPR-BSTNK+2(8)00&
IBM Global Services
2005 IBM Corporation 10 March-2005 Coding 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&

IBM Global Services
2005 IBM Corporation 11 March-2005 Coding 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 # &934VBDPL-SORTKRI&
/: WHEN OTHERS
/ Case # &999VBDPL-SORTKRI&
/: ENDCASE

IBM Global Services
2005 IBM Corporation 12 March-2005 Coding 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
IBM Global Services
2005 IBM Corporation 13 March-2005 Coding in the SAPScript editor | 9.03
Commands (Contd.)
The command ADDRESSENDADDRES 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
IBM Global Services
2005 IBM Corporation 14 March-2005 Coding 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.

IBM Global Services
2005 IBM Corporation 15 March-2005 Coding 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
IBM Global Services
2005 IBM Corporation 16 March-2005 Coding 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
IBM Global Services
2005 IBM Corporation 17 March-2005 Coding 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 IT
INCLUDE SD_TEXT OBJECT TEXT ID SDVD PARAGRAPH HT
IBM Global Services
2005 IBM Corporation 18 March-2005 Coding 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.

IBM Global Services
2005 IBM Corporation 19 March-2005 Coding 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& * </>
IBM Global Services
2005 IBM Corporation 20 March-2005 Coding 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
IBM Global Services
2005 IBM Corporation 21 March-2005 Coding 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
IBM Global Services
2005 IBM Corporation 22 March-2005 Coding 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.
IBM Global Services
2005 IBM Corporation 23 March-2005 Coding 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.


IBM Global Services
2005 IBM Corporation 24 March-2005 Coding 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. CASEENDCASE and IFELSEENDIF 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.




IBM Global Services
2005 IBM Corporation 25 March-2005 Coding 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 ?

You might also like