SAPScript Appx A
SAPScript Appx A
Contents
Overview................................................................................................................ A–3
Overview of SAPscript Control Commands........................................................A–4
Overview of Formatting Options..........................................................................A–5
Syntax of Control Commands..............................................................................A–6
ADDRESS: Formatting of addresses......................................................................A–6
BOTTOM: Define footer text in a window................................................................A–9
BOX, POSITION, SIZE: Boxes, lines, shading........................................................A–9
CASE: Case distinction......................................................................................... A–13
DEFINE: Value assignment to text symbols..........................................................A–13
HEX: Hexadecimal Data........................................................................................A–14
IF: Conditional text output.....................................................................................A–15
INCLUDE: Include other texts...............................................................................A–17
NEW-PAGE: Explicit form feed.............................................................................A–18
NEW-WINDOW: Next window MAIN.....................................................................A–19
PERFORM: Calling ABAP Subroutines.................................................................A–19
PRINT-CONTROL: Insert print control character..................................................A–21
PROTECT: Protect from page break.....................................................................A–22
RESET: Initialize outline paragraphs.....................................................................A–23
SET COUNTRY: Country-specific formatting........................................................A–25
SET DATE MASK: Formatting of date fields.........................................................A–26
SET SIGN: The Position of +/-..............................................................................A–27
SET TIME MASK: Formatting of time fields...........................................................A–28
STYLE: Change style............................................................................................ A–28
SUMMING............................................................................................................. A–29
TOP: Set header text in MAIN...............................................................................A–29
2 Release 4.0B
Appendix A: SAPscript Control Commands
Syntax of Control Commands
Overview
4 Release 4.0B
Appendix A: SAPscript Control Commands
Syntax of Control Commands
Formatting options format variables and override the format described in the Dictionary.
Formatting options are always specified within &-& variable brackets.
Some of the control commands are global settings, which are valid
until they are explicitly switched off. Therefore it is important to
know that, on a page, the MAIN window is always processed first.
For example, if you want to set the date format with the control
command SET DATE FORMAT and this format must be valid for the
entire form, then specify this command at the top of MAIN.
6 Release 4.0B
Appendix A: SAPscript Control Commands
Syntax of Control Commands
Syntax:
/: ADDRESS [DELIVERY] [PARAGRAPH a] [PRIORITY p] [LINES l]
/: TITLE title
/: NAME name1[,name2[,name3[,name4]]]
/: STREET street
/: POBOX PO box [CODE zip code]
/: POSTCODE zip code
/: CITY town1[,town2]
/: REGION region
/: COUNTRY country
/: FROMCOUNTRY from country
/: ENDADDRESS
Both formatting data and address data are parameters. Address data is formatted for output
based on the COUNTRY, PRIORITY and LINES parameters. As the default, the P.O. Box is used,
if it is available, rather than the street address.
DELIVERY defines the street address.
If this parameter is selected, the system prints the street address on the layout output
instead of the P.O. Box.
PARAGRAPH defines in which paragraph format the address is output.
If the parameter is not defined, the address is output in the default paragraph format.
PRIORITY defines which address lines can be omitted if there is not enough space on the
output.
You can enter a combination of the following values:
A form of address
P mandatory blank line 1
Q mandatory blank line 2
2 name2
3 name3
4 name4
L country name
S line for the street
O line for the city
LINES define how many lines are available to format the address.
If the address data cannot be completely formatted due to an insufficient number of lines,
the data entered in the parameter PRIORITY is omitted. If the LINES specification is missing
and this command is in a form window whose type is not MAIN, the lines available for the
address layout are automatically calculated with the current output line item and window
size.
TITLE is a required form of address.
NAME means that up to four separate names, separated by commas, can be defined.
STREET means the street specification, including address number.
POBOX is the Post Office box number.
CODE is the P.O. box, postal, or zip code, if this code is different from the postal code of
the city.
Example:
/: ADDRESS
/: TITLE ‘Company’
/: NAME ‘Widget Technology, Inc.’, ‘All Kind of Widgets’
/: STREET ‘1005 Lido Lane’
/: POBOX ‘2935’ CODE ‘94400’
/: POSTCODE ‘94404’
/: CITY ‘Foster City’
/: REGION ‘CA’
/: COUNTRY ‘USA’
/: FROMCOUNTRY ‘USA’
/: ENDADDRESS
This list generates the following address:
Company
Widget Technology, Inc.
All Kind of Widgets
PO box 2935
Foster City, CA 94400
If the DELIVERY supplement is specified for the ADDRESS command, then the
street, not the P.O. Box, is entered.
Company
Widget Technology, Inc.
All Kind of Widgets
1005 Lido Lane
Foster City, CA 94404
8 Release 4.0B
Appendix A: SAPscript Control Commands
Syntax of Control Commands
BOX
Syntax:
/: BOX [XPOS] [YPOS] [WIDTH] [HEIGHT] [FRAME] [INTENSITY]
This command draws a box of the specified size at the specified position. For each parameter
(XPOS, YPOS, WIDTH, HEIGHT, and FRAME), both a measurement and a unit of measure must
be specified. The INTENSITY parameter should be entered as a percentage between 0 and
100.
XPOS, YPOS specify the upper left corner of the box, relative to POSITION command
values.
Default is the values specified in the POSITION command.
The following calculation is performed internally to determine the absolute output position
of a box on the page:
X(abs) = XORIGIN + XPOS
Y(abs) = YORIGIN + YPOS
WIDTH determines the width of the box.
Default: WIDTH value of the SIZE command.
HEIGHT determines height of the box.
Default: HEIGHT value of the SIZE command.
FRAME determines the thickness of frame.
Default: 0 (no frame).
INTENSITY determines the box contents as a grayscale percentage.
Default: 100 (full black)
When determining the measurements, use decimal numbers to specify literal values (like
ABAP numeric constants) and enclose these values in inverted commas. Use a period for the
decimal point character. See also the examples listed below.
Use the following units of measure:
TW (twip)
PT (point)
IN (inch)
MM (millimeter)
CM (centimeter)
LN (line)
CH (character)
The following conversion factors apply:
1 TW = 1/20 PT
1 PT = 1/72 IN
1 IN = 2.54 CM
1 CM = 10 MM
1 CH = height of a character relative to the CPI specification in the form header
1 LN = height of a line relative to the LPI specification in the form header
Example:
10 Release 4.0B
Appendix A: SAPscript Control Commands
Syntax of Control Commands
/: BOX FRAME 10 TW
Draws a frame around the current window with a frame thickness of 10 TW (=
0.5 PT).
/: BOX INTENSITY 10
Fills the window background with shadowing having a gray scale of 10 %.
/: BOX HEIGHT 0 TW FRAME 10 TW
Draws a horizontal line across the complete top edge of the window.
/: BOX WIDTH 0 TW FRAME 10 TW
Draws a vertical line along the complete height of the left hand edge of the
window.
/: BOX WIDTH '17.5' CM HEIGHT 1 CM FRAME 10 TW INTENSITY 15
/: BOX WIDTH '17.5' CM HEIGHT '13.5' CM FRAME 10 TW
/: BOX XPOS '10.0' CM WIDTH 0 TW HEIGHT '13.5' CM FRAME 10 TW
/: BOX XPOS '13.5' CM WIDTH 0 TW HEIGHT '13.5' CM FRAME 10 TW
Draws two rectangles and two lines to construct a table of three columns with
a highlighted heading.
POSITION
Syntax:
/: POSITION [XORIGIN] [YORIGIN] [WINDOW] [PAGE]
This command sets the origin for the coordinate system used by the XPOS and YPOS
parameters of the BOX command. When a window is first started, the POSITION value is set to
refer to the upper left corner of the window (default setting). If a parameter value does not
have a leading sign, then its value is interpreted as an absolute value, which is a value that
specifies an offset from the upper-left corner of the output page. If a parameter value is
specified with a leading sign, then the new value of the parameter is calculated relative to the
old value. If a parameter specification is missing, then this parameter is unchanged.
XORIGIN, YORIGIN is the origin of the coordinate system.
WINDOW sets the values for the left and upper edges to be the same of those of the
current window (default setting).
PAGE sets the values for the left and upper edges to be the same as the current output
page (XORIGIN = 0 cm, YORIGIN = 0 cm).
Example:
/: POSITION WINDOW
Sets the origin for the coordinate system to the upper-left corner of the
window.
/: POSITION XORIGIN 2 CM YORIGIN '2.5 CM'
Sets the origin for the coordinate system to a point 2 cm from the left edge
and 2.5 cm from the upper edge of the output page.
/: POSITION XORIGIN '-1.5' CM YORIGIN -1 CM
Shifts the origin for the coordinates 1.5 cm to the left and 1 cm up.
SIZE
Syntax:
/: SIZE [WIDTH] [HEIGHT] [WINDOW] [PAGE]
This command sets the values of the WIDTH and HEIGHT parameters used in the BOX
command. When a window is first started, the SIZE value is set to the same values as the
window (default setting). If one of the parameter specifications is missing, then no change is
made to its current value. If a parameter value does not have a leading sign, then its value is
interpreted as an absolute value. If a parameter value is specified with a leading sign, then
the new value of the parameter is calculated relative to the old value.
WIDTH, HEIGHT sets the dimensions of the rectangle or line.
WINDOW sets the values for the width and height relative to the values of the current
window (default setting).
PAGE sets the values for the width and height to the values of the current output page.
Example:
/: SIZE WINDOW
Sets WIDTH and HEIGHT to the current window dimensions.
/: SIZE WIDTH '3.5' CM HEIGHT '7.6' CM
Sets WIDTH to 3.5 cm and HEIGHT to 7.6 cm.
/: POSITION WINDOW
/: POSITION XORIGIN -20 TW YORIGIN -20 TW
/: SIZE WIDTH +40 TW HEIGHT +40 TW
/: BOX FRAME 10 TW
A frame is added to the current window. The frame edges extends beyond the
window itself, to avoid obscuring the leading and trailing text characters.
12 Release 4.0B
Appendix A: SAPscript Control Commands
Syntax of Control Commands
Example:
/: DEFINE &re& = ‘Your correspondence of 3/17/94’
/: DEFINE &symbol1& = ‘xxxxxxx’
/: DEFINE &symbol2& = ‘yyy&symbol1&’
/: DEFINE &symbol1& = ‘zzzzzzz’
Result: &symbol2& yyyzzzzzzz
The assigned value may have a maximum of 60 characters, but it can also contain more
symbols. When a symbol is defined using DEFINE, symbols which occur in the value are not
immediately replaced by their value. They are replaced only when the target symbol is
output.
If operator := is used in DEFINE, the symbols that occur in the value to be assigned are
immediately replaced by their current values. The resulting character string is only then
assigned to the target symbol when all occurring symbols have been replaced. The length of
the value is limited to 80 characters, and the target symbol must be a text symbol.
Syntax:
/: DEFINE &symbolname& := ‘value’
14 Release 4.0B
Appendix A: SAPscript Control Commands
Syntax of Control Commands
Example:
/* Creator: report ZQVNTE30 date 19940705 time 125129 user SAPSCRIPT
/= 1B2A7230461B2A743735521B2A7231411B2A62304D1B2A62343057FFFFFFFFFFFF
/= FF1B2A62343057FFFFFFFFFFFFC0007D00DFC0F7D0000000000000000000000017
/: ENDHEX
This data will be printed only by an HP PCL printer (7.5 cm of space will allocated
on the page for the output of the data and the output cursor will be indented 2.25
cm to the right of the form window edge).
= or EQ equals
< or LT less than
> or GT greater than
<= or LE less than or equal to
>= or GE greater than or
equal to
<> or NE not equal
The sequence of processing the logical operations and the sequence of processing the
conditions is always from left to right. There is no order of binding, and bracketing is not
allowed.
Comparison is always carried out as a literal comparison, that is, symbols are compared in
their formatted form as a character string and not with their internal representation. This
comparison must be taken into account for program symbols whose format depends on
different parameters. Examples include currency fields that are output with different number
of places after the decimal point depending on the currency key, or that use a comma or a
period as the decimal separator depending on the setting.
The IF command can be extended to make a two-sided case distinction with the ELSE
command. If the specified IF condition is true, then the lines listed between IF and ELSE are
formatted, otherwise the lines between ELSE and ENDIF are formatted.
Syntax:
/: IF Condition
:
/: ELSE
:
/: ENDIF
A multi-level case distinction is possible using the ELSEIF command.
Syntax:
/: IF Condition
:
/: ELSEIF Condition
:
/: ELSE
:
16 Release 4.0B
Appendix A: SAPscript Control Commands
Syntax of Control Commands
/: ENDIF
You can use as many ELSEIF commands as required. The specification of an ELSE command is
optional in this case.
The condition must not extend over several lines, and must be
contained in one line with the IF or ELSEIF command.
IF commands can also be nested.
An IF command must always end with ENDIF. If this command is
forgotten, and if the condition is not true, nothing more is
output after the IF command.
If a syntax error is found when interpreting these commands,
the corresponding command is not executed. This can have
various effects on the following text output. If, for example, the
IF statement is incorrectly structured, since IF is missing, the
following ELSEIF or ELSE commands are ignored. All lines are
output.
Example:
/: INCLUDE MYTEXT
The text MYTEXT is included in the language of the calling text.
/: INCLUDE MYTEXT LANGUAGE ‘E’ PARAGRAPH ‘A1’
The text with the name MYTEXT and the language E is included, regardless of
the language in which the calling text is created. The paragraph format A1 is
valid as the standard paragraph for this call.
Optional specifications:
49. LANGUAGE
If a language is unspecified, the calling text’s language or the form is set for the text to be
included. If a language is specified, the text is always loaded in this language, regardless
of the language of the calling text.
50. PARAGRAPH
The text to be included is formatted with its style allocation. With this parameter, the
standard paragraph of this style can be redefined for the current call. All * paragraphs of
the inserted text are formatted with the paragraph specified here.
51. NEW-PARAGRAPH
The first line of the included text has this format flag, provided it is not a command or
comment line. If the optional entry PARAGRAPH (see above) is empty, all * paragraphs of
the included text are formatted with the paragraph np specified with NEW-PARAGRAPH.
52. OBJECT
To completely specify a text, create additional specifications about the text object. There
are different rules and restrictions for this specification that depends on the calling text’s
object type. All texts can be included in a form. If no object is entered here, TEXT is used
(standard texts). With a documentation text (object DOKU), you can only include
documentation texts. This object is assumed even if no object is specified in this
environment.
Only hypertext or documentation text can be included into a hypertext (object DSYS). If
the OBJECT specification is missing, DSYS is set as a default value.
Only standard text (object TEXT), documentation text or hypertext can be included in any
other type of text. The default object is TEXT if nothing is entered.
53. ID
The text ID allows further text types within an object, is a further part of the text key. If the
ID is not entered, the default Include ID from table TTXID is used to call text. If the
specification is not in this table, the text ID of the calling text is used.
The ID and the object are now the basis of a further consistency check:
All text IDs are allowed for a form.
Only documentation texts with the text IDs TX (general texts), UO (authorization objects),
and documentation texts (with the same text ID as the calling documentation text) may be
included in documentation texts.
All DSYS texts may be included in DSYS texts, regardless of their ID. Documentation texts
that will be inserted may only have IDs TX and UO.
Standard texts with the allowed text IDs, DSYS texts with IDs, and documentation texts
with IDs TX and UO may be included in the text types.
18 Release 4.0B
Appendix A: SAPscript Control Commands
Syntax of Control Commands
Example:
/: NEW-PAGE
The current page is completed and the text in the following lines is written on
the next page as determined in the form.
/: NEW-PAGE S1
Same as before, but S1 is accessed as the next page.
20 Release 4.0B
Appendix A: SAPscript Control Commands
Syntax of Control Commands
Example:
From within a SAPscript form, a subroutine GET_BARCODE in the ABAP
program QCJPERFO is called. Then the simple barcode contained there (‘First
page’, ‘Next page’, ‘Last page’) is printed as local variable symbol.
After performing PRINT-CONTROL, SAPscript inserts a blank at the start of the following line. If
this is not required, this line must have the paragraph format “=.”
22 Release 4.0B
Appendix A: SAPscript Control Commands
Syntax of Control Commands
the name of an outline paragraph is entered in RESET, the numbering of this paragraph, is
initialized with subordinate outline levels.
Syntax:
/: RESET paragraph format
The paragraph format specifies the outline paragraph to be initialized.
Example:
Assume that paragraph N1 is defined in the style that you are using. This
paragraph should be used for listings and it each time generates an output of
a list number. This is the SAPscript editor:
AS If you want to work with the SAP R/3 System, proceed as
follows:
N1 Make sure that you have a PC
N1 Switch on the PC
N1 Click on the SAP icon.
AS The SAP logon screen appears. To log on, you must carry out the
following steps:
/: RESET N1
N1 Enter your user ID
N1 Enter your password
N1 Choose the application you require
Result:
If you want to work with the SAP R/3 System, proceed as follows:
1. Make sure that you have a PC
2. Switch on the PC
3. Click on the SAP icon.
The SAP logon screen appears. To log on, you must carry out the following
steps:
1. Enter your user ID
2. Enter your password
3. Choose the application you require.
Example:
If the RESET command between the two lines in the previous example is
missing, then both of the listings would be sequentially numbered:
Result:
If you want to work with the SAP R/3 System, proceed as follows:
1. Make sure that you have a PC
2. Switch on the PC
3. Click on the SAP icon.
The SAP logon screen appears. To log on, you must carry out the following
steps:
4. Enter your user ID
5. Enter your password
6. Choose the application you require.
Example:
/: SET COUNTRY ‘CAN’
/: SET COUNTRY &country key&
By entering an empty country name, you can return to the values set in the
user master record.
/: SET COUNTRY ‘ ‘
The corresponding ABAP command is called internally by SAPscript.
24 Release 4.0B
Appendix A: SAPscript Control Commands
Syntax of Control Commands
DD Day (two-digit)
DDD Day name abbreviated
DDDD Day name in full
MM Month (two-digit)
MMM Month name
abbreviated
MMMM Month name in full
YY Year (two-digit)
YYYY Year (four-digit)
All other characters in the mask are interpreted as text and copied correspondingly.
Example:
Assume that the current system date is March 1 st 1994.
/: SET DATE MASK = ‘Walldorf, DD.MM.YY’
&DATE&
Result: Walldorf, 01.03.94
/: SET DATE MASK = ‘MMMM, DD. YYYY’
&DATE&
Result: March, 01. 1994
By specifying an empty string as the date mask, you can switch back to the default display:
/: SET DATE MASK = ‘ ‘
The texts for the month and day names, shortened or in full, are stored language-
dependently in table TTDTG under the following arguments:
Argument Description
26 Release 4.0B
Appendix A: SAPscript Control Commands
Syntax of Control Commands
Example:
Assume that the current time is 10:08:12.
/: SET TIME MASK = ‘HH:MM’
&TIME&
Result: 10:08
/: SET TIME MASK = ‘HH hours MM minutes’
&TIME&
Result: 10 hours 08 minutes
By specifying an empty string as a time mask, you can switch back to the default display:
/: SET TIME MASK = ‘ ‘
SUMMING
Program symbols can be added with the SUMMING command. The command needs to be
defined only once. Each time that the specified symbol is edited, its current value is added to
the sum field. Several program symbols can also be added in a sum field.
Syntax:
/:SUMMING program symbol INTO sum symbol
Since SAPscript can not dynamically define sum fields, the sum symbol must be in a calling
program structure that was declared with TABLES.
/: ENDTOP
Those text lines between the two commands will be output at the top of MAIN.
To switch a header text off, enter the command pair TOP .. ENDTOP, with no lines in between:
/: TOP
/: ENDTOP
Header text will not appear on subsequent pages.
28 Release 4.0B
Appendix A: SAPscript Control Commands
Syntax of Control Commands
Example:
Assume that &SAPSCRIPT-COUNTER_1& initially has the value 2.
&SAPSCRIPT-COUNTER_1& 2
&SAPSCRIPT-COUNTER_1(+)& 3
&SAPSCRIPT-COUNTER_1(-)& 2
&SAPSCRIPT-COUNTER_1(-)& 1
&SAPSCRIPT-COUNTER_1(+0)&
&SAPSCRIPT-COUNTER_1(+)& 3
Date Mask
To format date fields, use the SAPscript SET DATE MASK command. Executing this command
causes all subsequent date fields to be printed with the specified formatting.
Syntax
/: SET DATE MASK = 'date_mask'
The following table provides templates may be used in the date mask:
Template Description
Any other characters occurring in the mask are interpreted as simple text and are copied
directly to the output.
30 Release 4.0B
Appendix A: SAPscript Control Commands
Syntax of Control Commands
Example:
Assuming a current system date of March 1st, 1997.
/: SET DATE MASK = 'Foster City, MM.DD.YY'
&DATE& Foster City, 03.01.97
&DATE(Z)& Foster City, 3.1.97
/: SET DATE MASK = 'MMMM DD, YYYY'
&DATE& March 01, 1997
You can revert to the standard setting by using the SET DATE MASK command again with an
empty string in place of the date mask:
/: SET DATE MASK = ' '
Example:
In this example the PLMK-SOLLWERT field is assumed to have the value
123456.78 and to be of data type FLTP.
&PLMK-SOLLWERT& +1.23456780000000E+05
&PLMK-SOLLWERT(E3)& +123.456780000000E+03
&PLMK-SOLLWERT(E6)& +0.12345678000000E+06
&PLMK-SOLLWERT(E0)& +123456.780000000
&PLMK-SOLLWERT(E)& +123456.780000000
Fill characters
Leading spaces in a value can be replaced with a fill character. The character immediately
following the F in the specification is used as the fill character.
Syntax:
&symbol(Ff)&
Example:
The figure for customer sales in the KNA1-UMSAT field is $700. The Dictionary
description of the field specifies an output length of eight.
&KNA1-UMSAT& 700.00
&KNA1-UMSAT(F*)& **700.00
&KNA1-UMSAT(F0)& 00700.00
Example:
&ITCDP-TDULPOS& 100.00-
&ITCDP-TDULPOS(<)& -100.00
The SET SIGN LEFT control command specifies that all subsequent
symbols with a numeric value should have a left-justified leading
sign. Using this control command means that there is then no need
to repeat the < option for each individual symbol.
32 Release 4.0B
Appendix A: SAPscript Control Commands
Syntax of Control Commands
Use the SET SIGN RIGHT control command to switch back to the
default setting to output the leading sign.
Number of decimals
A program symbol of one of the data types DEC, QUAN and FLTP can contain decimal place
data. This option overrides the Dictionary definition for the number of decimal places to
format this symbol value.
Syntax:
&symbol(.n)&
Example:
The EKPO-MENGE field contains the value 1234.56. The Dictionary definition
specifies three decimal places and an output length of 17.
&EKPO-MENGE& 1,234.560
&EKPO-MENGE(.1)& 1,234.6
&EKPO-MENGE(.4)& 1,234.5600
&EKPO-MENGE(.0)& 1,235
Offset
Specifying an offset of “n” causes the “n” left-most characters of the symbol value will not be
displayed. If the offset specified is greater than the length of the value, nothing is output.
Syntax:
&symbol+n&
Example:
If symbol has the value 123456789, the following will be displayed:
&symbol& 123456789
&symbol+3& 456789
&symbol+7& 89
&symbol+12&
&symbol+0& 123456789
Example:
Assuming the current date is 1/1/1994.
&DAY& 01
&DAY(Z)& 1
Example:
The ITCDP-TDULPOS field contains the value -100.00. The ABAP Dictionary
definition for this field includes a leading sign.
&ITCDP-TDULPOS& 100.00-
&ITCDP-TDULPOS(S)& 100.00
Example:
The EKPO-MENGE field contains the value 1234.56. The Data Dictionary
definition specifies three decimal places and the output length is set to 17.
&EKPO-MENGE& 1,234.560
&EKPO-MENGE(T)& 1234.560
34 Release 4.0B
Appendix A: SAPscript Control Commands
Syntax of Control Commands
Output length
If you need only a part of the symbol value, or if the output has to fit in an on-screen box or
field without overlapping the edges of this area, use an output length specification to define
how many character positions should be copied from the value.
If a length is specified that is greater than the current value length, then spaces are
appended to the symbol value.
The character * specifies the program symbol length. This specification causes the symbol
value to be output based on the output length defined in the ABAP Dictionary.
Syntax:
&symbol(l)&
Example:
If symbol has the value 123456789.
&symbol(3)& 123
&symbol(7)& 1234567
An output length specification can be combined with an offset specification.
The specified length is then counted from the specified offset position.
&symbol+4(3)& 567
Example:
The SYST-UNAME field contains the logon name of a user called Einstein. The
ABAP Dictionary entry for this field contains an output length of 12.
&SYST-UNAME&... Einstein...
&SYST-UNAME(9)&... Einstein ...
&SYST-UNAME(*)&... Einstein ...
Ensure that the symbol, the pretext and the posttext, all appear on
a single line of the editor. This may mean that you have to use a
long line (paragraph attribute = or /= ) in the editor.
The apostrophe character delimits these texts. If this character also
appears as part of one of these texts, then it must be written twice
at this point to avoid misinterpretation. A pretext or posttext may
contain symbols in addition to normal text. These symbols are
subject to the restriction that these symbols may not have a
pretext or a posttext.
Example:
The KNA1-PFACH field contains a customer PO Box number. Since “PO Box” is
not stored in the field with the value, you would normally write the following
for the PO Box line of an address:
PO Box &KNA1-PFACH&
However, if no “P.O. Box” has been specified then “PO Box” would still appear
on its own in the address. Prevent this step by using pretext and/or posttext
(in this case pretext).
PO Box &KNA1-PFACH& PO Box
&'PO Box 'KNA1-PFACH&
If “P.O. Box” is specified, then this information will be displayed with the
appropriate text in the usual way.
&'PO Box 'KNA1-PFACH& PO Box 123456
Right-justified output
Symbol values other than numeric values are normally formatted to be left-justified. Right-
justified formatting can be specified with the R option. This option has to be used with an
output length specification.
Syntax:
&symbol(R)&
Example:
If symbol has the value 1234.
&symbol& 1234
&symbol(8R)& 1234
Space compression
The symbol value is viewed as a sequence of “words,” each separated from the next by either
one or a string of space characters. The C option replaces each string of space characters
36 Release 4.0B
Appendix A: SAPscript Control Commands
Syntax of Control Commands
with a single space and shifting “words” to the left to close gaps. Leading spaces are
completely removed. The results are the same as if the ABAP command CONDENSE was used.
Syntax:
&symbol(C)&
Example:
Assuming ' Albert Einstein ' is the symbol value.
&symbol& Albert Einstein
&symbol(C)& Albert Einstein
Example:
Assuming KNA1-UMSAT contains the value 0 and the currency is USD.
&KNA1-UMSAT& 0.00
&KNA1-UMSAT(I)&
If the field contains an amount other than 0, this value will be output in the
usual way.
&KNA1-UMSAT& 700.00
&KNA1-UMSAT(I)& 700.00
Time Mask
You can use the SAPscript SET TIME MASK command to format time fields in a way that differs
from the standard setting. Executing this command causes all subsequent time fields to be
printed with the specified formatting.
Syntax:
/: SET TIME MASK = 'time_mask'
The following tables provides templates may be used in the time mask:
Template Description
Any other characters occurring in the mask are interpreted as simple text and are copied
directly to the output.
Example:
Assuming the current time is 10:08:12.
&TIME& -> 10:08:12
/: SET TIME MASK = 'HH:MM'
&TIME& -> 10:08
/: SET TIME MASK = 'HH hours MM minutes'
&TIME& -> 10 hours 08 minutes
&TIME(Z)& -> 10 hours 8 minutes
You can revert to the standard setting by using the SET TIME MASK
command again with an empty string in place of the time mask:
/: SET TIME MASK = ' '
System Variables
&SAPSCRIPT-COUNTER_x& (x = 0.. 9):
These fields represent ten counter variables that you can use in your text and forms for any
counting purposes. You can use the ‘+’ and ‘-’ formatting options to increment or decrement
a counter before its value is printed. You can use the DEFINE control command to assign any
specific value to a counter.
&SAPSCRIPT-DRIVER&:
SAPscript formats a text for a specific output device. The initial formatting is independent of
the specific language of this device. SAPscript then calls a driver to convert the device-
independent format to device-specific control commands. This field contains the name of the
driver.
POST Postscript driver
HPL2 HP Laserjet driver for the PCL4/PCL5 languages
PRES Driver for output devices using the PRESCRIBE language
The available drivers are stored in table TSP09.
&SAPSCRIPT-SUBRC&
After executing an INCLUDE statement, this contains a value that indicates whether the
INCLUDE was found or not. This value can be queried with IF....
INCLUDE found = 0 and INCLUDE not found = 4
&SAPSCRIPT-FORMPAGES&
This contains the total number of pages output in a SAPscript form (all output between the
functions START_FORM and END_FORM). The state of the page counter on the individual form
pages (START,HOLD,INC) is not taken into account.
38 Release 4.0B
Appendix A: SAPscript Control Commands
Syntax of Control Commands
Using this symbol impairs performance, since all output data for
every form must be retained internally to fill the symbol.
&SAPSCRIPT-JOBPAGES&
This contains the total number of pages output in a SAPscript print run (all output between
the functions OPEN_FORM and CLOSE_FORM). The state of the page counter on the individual
form pages (START,HOLD,INC) is not taken into account.
Using this symbol impairs performance, since all output data for
every print job must be retained internally to fill the symbol.
&SAPSCRIPT-TELELAND&
This contains the country identifier for the fax destination with fax output with SAPscript (field
ITCPO-TDTELELAND for the parameter OPTIONS of function OPEN_FORM).
&SAPSCRIPT-TELENUM&
This contains the local fax number for the fax destination with fax output with SAPscript (field
ITCPO-TDTELENUM for the parameter OPTIONS of function OPEN_FORM).
&SAPSCRIPT-TELENUME&
This contains the complete fax number for the fax destination with fax output with SAPscript
(field ITCPO-TDTELENUME for the parameter OPTIONS of function OPEN_FORM).
Variables of Structure SYST
All variables of structure SYST, called system variables, can be used in the form. Of particular
interest are the variables for the system date and time. These variables indicate the date and
time that the output was created. For the system date, use SYST-DATUM variable, for the
system time, use SYST-UZEIT. Note that you have the formatting options for date and time
variables.