We are hiring and constantly growing! Have a look through our vacancies to find the right role for you!
... $[WIDTH = len$]
$[ALIGN = LEFT$|RIGHT$|CENTER$|(dobj)$|expr$]
$[PAD = c$]
$[CASE = RAW$|UPPER$|LOWER$|(dobj)$|expr$]
$[SIGN = LEFT$|LEFTPLUS$|LEFTSPACE$|RIGHT$|RIGHTPLUS$|RIGHTSPACE$|(dobj)$|expr$]
$[EXPONENT = exp$]
$[DECIMALS = dec$]
$[ZERO = YES$|NO$|(dobj)$|expr$]
$[XSD = YES$|NO$|(dobj)$|expr$]
$[STYLE = SIMPLE$|SIGN_AS_POSTFIX$|SCALE_PRESERVING
$|SCIENTIFIC$|SCIENTIFIC_WITH_LEADING_ZERO
$|SCALE_PRESERVING_SCIENTIFIC$|ENGINEERING
$|(dobj)$|expr$]
$[CURRENCY = cur$]
$[NUMBER = RAW$|USER$|ENVIRONMENT$|(dobj)$|expr$]
$[ALPHA = IN$|OUT$|RAW$|(dobj)$|expr$]
$[DATE = RAW$|ISO$|USER$|ENVIRONMENT$|(dobj)$|expr$]
$[TIME = RAW$|ISO$|USER$|ENVIRONMENT$|(dobj)$|expr$]
$[TIMESTAMP = SPACE$|ISO$|USER$|ENVIRONMENT$|(dobj)$|expr$]
$[TIMEZONE = tz$]
$[COUNTRY = cty$] ...
1. ... WIDTH = len ...
2. ... ALIGN = LEFT$|RIGHT$|CENTER$|(dobj)$|expr ...
3. ... PAD = c ...
4. ... CASE = RAW$|UPPER$|LOWER$|(dobj)$|expr ...
5. ... SIGN = LEFT$|LEFTPLUS$|LEFTSPACE$|RIGHT$|RIGHTPLUS$|RIGHTSPACE$|(dobj)$|expr ...
6. ... EXPONENT = exp ...
7. ... DECIMALS = dec ...
8. ... ZERO = YES$|NO$|(dobj)$|expr ...
9. ... XSD = YES$|NO$|(dobj)$|expr ...
10. ... STYLE = ...$|(dobj)$|expr ...
11. ... CURRENCY = cur ...
12. ... NUMBER = RAW$|USER$|ENVIRONMENT$|(dobj)$|expr ...
13. ... ALPHA = IN$|OUT$|RAW$|(dobj)$|expr ...
14. ... DATE = RAW$|ISO$|USER$|ENVIRONMENT$|(dobj)$|expr ...
15. ... TIME = RAW$|ISO$|USER$|ENVIRONMENT$|(dobj)$|expr ...
16. ... TIMESTAMP = SPACE$|ISO$|USER$|ENVIRONMENT$|(dobj)$|expr ...
17. ... TIMEZONE = tz ...
18. ... COUNTRY = cty ...
These formatting options override the predefined formats of embedded expressions in string templates. The formatting options are specified as optional keyword parameters to which an actual parameter is assigned.
Actual parameters with fixed values can be specified as follows:
The formatting options that can be specified depend on the data type of the embedded expression. The formatting options NUMBER, DATE, TIME, TIMESTAMP, and COUNTRY are mutually exclusive.
If a formal parameter or a field symbol with a generic data type is specified as an embedded expression, only those formatting options can be specified that are allowed for all possible concrete data types.
The specifications (dobj) and expr together represent a summary
functional operand position. Unlike the regular
functional operand positions, however,
the data object dobj must be placed in parentheses to distinguish it clearly from a parameter specified as a key word.
... WIDTH = len ...
This formatting option defines the length of the string represented by the embedded expression as the value of len, where len is a numeric expression position.
The option WIDTH can be specified for all data types of the embedded expression. If the value
of len is less than the minimum required length, it is ignored. This means that the predefined
length cannot be reduced but only increased. By default, a string is extended on the right if it is
enlarged, and padded with blanks. This default setting can be overridden using the formatting options ALIGN and PAD.
The length of the result of the following string template is 20. It consists of 4 digits, a decimal separator, and 15 trailing blanks.
... ALIGN = LEFT$|RIGHT$|CENTER$|(dobj)$|expr ...
This formatting option defines the alignment of the string represented by the embedded expression. It only has an effect if WIDTH is used at the same time to define a length that is greater than the minimum required length.
The values for the alignment are fixed. The following table shows the key words and the associated values from the class CL_ABAP_FORMAT that can be specified as dobj or expr:
Keyword | Value of dobj or expr | Effect |
LEFT | CL_ABAP_FORMAT=>A_LEFT | Left-aligned |
RIGHT | CL_ABAP_FORMAT=>A_RIGHT | Right-aligned |
CENTER | CL_ABAP_FORMAT=>A_CENTER | Centered |
The default setting is LEFT. Depending on the alignment, surplus characters in the result are
padded with blanks by default either on the right, left, or alternately left and right. This default setting can be overridden using the formatting option PAD.
The following string template creates the character string shown below it.
1 2 3-
String Templates, Alignments and Padding
... PAD = c ...
This formatting option defines the character used to pad surplus spaces in the result. It only has an effect if WIDTH is used at the same time to define a length that is greater than the minimum required length.
A data object of data type c or string can be specified for c, the first character
of which is used as padding. If the PAD option is not specified or if c is specified as an empty string, blanks are used as padding.
The following string template creates the character string shown below it.
_________X
See String Templates, Alignments and Padding
... CASE = RAW$|UPPER$|LOWER$|(dobj)$|expr ...
This formatting option defines the case of the string represented by the embedded expression. It can be specified for all data types of the embedded expression.
The values for the case are fixed. The following table shows the key words and the associated values from the class CL_ABAP_FORMAT that can be specified as dobj or expr:
Keyword | Value of dobj or expr | Effect |
RAW | CL_ABAP_FORMAT=>C_RAW | Unchanged |
UPPER | CL_ABAP_FORMAT=>C_UPPER | Uppercase |
LOWER | CL_ABAP_FORMAT=>C_LOWER | Lowercase |
The default setting is RAW.
The formatting option CASE affects the letters in a string. It is ignored by characters specified using PAD. In numeric data types, the "e" or "E" of an exponent is affected; in byte-like data types, the letters in a hexadecimal representation are affected. In a time stamp type, a "T" between date and time is affected. If the formatting option XSD is also specified, CASE affects the created asXML format.
The following string template creates the character string shown below it.
48656c6c6f20576f726c6421
... SIGN = LEFT$|LEFTPLUS$|LEFTSPACE$|RIGHT$|RIGHTPLUS$|RIGHTSPACE$|(dobj)$|expr ...
This formatting option defines the format of the +/- sign when the string represented by the embedded expression represents a numeric value. It can be specified only if the embedded expression has a numeric data type.
The values for the format of the plus/minus sign are fixed. The following table shows the key words and the associated values from the class CL_ABAP_FORMAT that can be specified as dobj or expr:
Keyword | Value of dobj or expr | Effect |
LEFT | CL_ABAP_FORMAT=>S_LEFT | "-" left without space, no "+" |
LEFTPLUS | CL_ABAP_FORMAT=>S_LEFTPLUS | "-" and "+" left without space |
LEFTSPACE | CL_ABAP_FORMAT=>S_LEFTSPACE | "-" left without space, blank left for "+" |
RIGHT | CL_ABAP_FORMAT=>S_RIGHT | "-" right without space, no "+" |
RIGHTPLUS | CL_ABAP_FORMAT=>S_RIGHTPLUS | "-" and "+" right without space |
RIGHTSPACE | CL_ABAP_FORMAT=>S_RIGHTSPACE | "-" left without space, blank right for "+" |
The default setting is LEFT.
The following string template creates the character string shown below it.
+1
... EXPONENT = exp ...
This formatting option defines the exponent as the value of exp when formatting floating point numbers, where exp is a numeric expression position. The option EXPONENT can be specified only if the embedded expression has a numeric data type. It cannot be specified in combination with the options TIMESTAMP or TIMEZONE.
The option EXPONENT only affects the data type f or if the option STYLE is specified with the value scientific.
If the value of the constant CL_ABAP_FORMAT=>EXP_PRESERVE is specified for exp, the exponent is used that matches the internal representation of the floating point number.
The following string template creates the character string shown below it.
0.66666666666666663, 6.6666666666666663E-01
... DECIMALS = dec ...
This formatting option defines the number of decimal places when formatting numeric values or time stamps as the value of dec, where dec is a numeric expression position. The option DECIMALS can be specified only if the embedded expression has a numeric data type or the time stamp type utclong. It cannot be specified together with the option CURRENCY.
The DECIMALS formatting option does not override the
predefined format for numeric types, specifying that thousands separators are not inserted.
The following string template creates the character string shown below it. If the conversion operator is not specified, the calculation type of the embedded expression is i.
-1.000, -0.667, -0.667
... ZERO = YES$|NO$|(dobj)$|expr ...
This formatting option defines the format of the numeric value zero. The option ZERO can be specified only if the embedded expression has a numeric data type. It cannot be specified together with the options TIMESTAMP or TIMEZONE.
The values for the format of the zero value are fixed. The following table shows the key words and the associated values from the class CL_ABAP_FORMAT that can be specified as dobj or expr:
Keyword | Value of dobj or expr | Effect |
YES | CL_ABAP_FORMAT=>Z_YES | The value zero is represented as a numeric value in accordance with the current formatting. |
NO | CL_ABAP_FORMAT=>Z_NO | The value zero is represented as an empty string. |
The default setting is YES.
The following string template creates the character string shown below it.
, 0
... XSD = YES$|NO$|(dobj)$|expr ...
This formatting option formats the value of the embedded expression in asXML format that is assigned to its data type. The option XSD can be specified for all elementary data types. It cannot be specified together with other formatting options except WIDTH, ALIGN, PAD, CASE, and ZERO.
The option XSD affects all data types listed under Mapping of Elementary ABAP Types, as specified there.
The values for the asXML format are fixed. The following table shows the key words and the associated values from the class CL_ABAP_FORMAT that can be specified as dobj or expr:
Keyword | Value of dobj or expr | Effect |
YES | CL_ABAP_FORMAT=>X_YES | The value of the embedded expression is formatted depending on its data type in accordance with the asXML format specified under Mapping of Elementary ABAP Types. If the data type refers to one of the domains specified under Mapping of Further XML Schema Data Types (except XSDQNAME), the format specified there is used. XML fragments cannot be mapped using the domain XSDANY. |
NO | CL_ABAP_FORMAT=>X_NO | Unchanged |
If the data type of the embedded expression has the type x or xstring, a formatting option CASE specified at the same time is ignored, unless it refers to the domain XSDUUID_RAW.
The formatting of an embedded expression with XSD generally produces the same result as applying the predefined identity transformation ID. Unlike CALL TRANSFORMATION, exceptions that can be raised during mapping are not wrapped but must be handled directly.
The following string template creates the character string shown below it. XSDBOOLEAN is a data element that refers to the special domain XSDBOOLEAN for the mapping of truth values.
true, false
String Templates, asXML Format
... STYLE = ...$|(dobj)$|expr ...
This formatting option defines the style of decimal floating point numbers. The option STYLE can be specified only if the embedded expression has a numeric data type. It cannot be specified together with the options CURRENCY, SIGN, TIMESTAMP, or TIMEZONE.
The values for the format of a decimal floating point number are fixed. The following table shows the key words and the associated values from the class CL_ABAP_FORMAT that can be specified as dobj or expr:
Keyword | Value of dobj or expr |
SIMPLE | CL_ABAP_FORMAT=>O_SIMPLE |
SIGN_AS_POSTFIX | CL_ABAP_FORMAT=>O_SIGN_AS_POSTFIX |
SCALE_PRESERVING | CL_ABAP_FORMAT=>O_SCALE_PRESERVING |
SCIENTIFIC | CL_ABAP_FORMAT=>O_SCIENTIFIC |
SCIENTIFIC_WITH_LEADING_ZERO | CL_ABAP_FORMAT=>O_SCIENTIFIC_WITH_LEADING_ZERO |
SCALE_PRESERVING_SCIENTIFIC | CL_ABAP_FORMAT=>O_SCALE_PRESERVING_SCIENTIFIC |
ENGINEERING | CL_ABAP_FORMAT=>O_ENGINEERING |
The numeric value of the string is converted to the data type decfloat34 and is handled as follows:
The general rules for embedded expressions apply to thousands separators and decimal separators. When combining other formatting options, the following applies:
The following string template creates the character string shown below it.
123.456E+03
Decimal Floating Point Number, Formatting with STYLE
... CURRENCY = cur ...
This formatting option defines the number of decimal places when formatting numeric values, dependent on a currency when specified in cur using a currency ID. The option CURRENCY can be specified only if the embedded expression has one of the numeric data types (b, s), i, int8, p and f, decfloat16 or decfloat34. It cannot be specified together with the options DECIMALS, STYLE, TIMESTAMP, or TIMEZONE. The option SIGN can also be used to control the formatting of the plus/minus sign.
The string is formatted with respect to its decimal places as follows for the individual numeric data types:
For the numeric data types i, p, and f, cur expects a currency ID from the
column WAERS of the DDIC database table TCURC. Two decimal places are used for every currency ID specified,
unless it is contained in the CURRKEY column of the DDIC database table TCURX. In this case, the number of decimal places is determined from the CURRDEC column of the corresponding line in the table TCURX.
The following string template creates the character string shown below it.
123456.78
... NUMBER = RAW$|USER$|ENVIRONMENT$|(dobj)$|expr ...
This formatting option defines the format of the decimal representation (decimal and thousands separators). The option NUMBER can only be specified if the embedded expression has a numeric data type. In addition to the exclusions mentioned above, it cannot be specified together with the options TIMESTAMP or TIMEZONE.
The values for the format of the decimal representation are fixed. The following table shows the key words and the associated values from the class CL_ABAP_FORMAT that can be specified as dobj or expr:
Keyword | Value of dobj or expr | Effect |
RAW | CL_ABAP_FORMAT=>N_RAW | The decimal separator is the period (.) and no thousands separators are inserted. |
USER | CL_ABAP_FORMAT=>N_USER | The decimal and thousands separators are based on the user master record. |
ENVIRONMENT | CL_ABAP_FORMAT=>N_ENVIRONMENT | The decimal and thousands separators are determined |
according to the current formatting setting of the language environment that can be set using SET COUNTRY.
The default setting is RAW.
If the formatting setting of the
language environment has not been set to a
country-specific format by means of
SET COUNTRY, the use of environment has the same effect as the use of user.
See character string templates, formatting settings
The following string template creates the character string shown below it.
1,000,000
... ALPHA = IN$|OUT$|RAW$|(dobj)$|expr ...
This formatting option adds or removes leading zeros from strings of digits. The option ALPHA can be specified only if the embedded expression has the data type string, c, or n. It cannot be specified together with other formatting options; apart from WIDTH and CASE.
The values for the format of the string of digits are fixed. The following table shows the key words and the associated values from the class CL_ABAP_FORMAT that can be specified as dobj or expr:
Keyword | Value of dobj or expr | Effect |
IN | CL_ABAP_FORMAT=>L_IN | If the character string of the embedded expression only contains an uninterrupted string of digits apart from leading and trailing blanks, the string of digits is right-aligned in a character string of a certain length (see below), which is padded on the left with the digit "0", if necessary. Otherwise, the characters of the character string of the embedded expression are left-aligned in the character string and padded with blanks on the right, if necessary. If the length is not sufficient, the string is truncated on the right in both cases. |
OUT | CL_ABAP_FORMAT=>L_OUT | If the character string of the embedded expression only contains an uninterrupted string of digits apart from leading and trailing blanks, leading zeros are removed from the string of digits and the remaining digits are left-aligned in a character string of a certain length (see below), which is padded on the right with blanks, if necessary Otherwise, all characters of the character string of the embedded expression are left-aligned in the character string and padded with blanks on the right, if necessary. If the length is not sufficient, the string is truncated on the right in both cases. |
RAW | CL_ABAP_FORMAT=>L_RAW | No formatting |
The length of the resulting character string is determined as follows:
The following string template creates the character string shown below it.
0000001234
String Templates, Strings of Digits
... DATE = RAW$|ISO$|USER$|ENVIRONMENT$|(dobj)$|expr ...
This formatting option defines the format of a date. The option DATE can be specified only if the embedded expression has the data type d.
The values for the format of the date are fixed. The following table shows the key words and the associated values from the class CL_ABAP_FORMAT that can be specified as dobj or expr:
Keyword | Value of dobj or expr | Effect |
RAW | CL_ABAP_FORMAT=>D_RAW | The content of the date field is passed without formatting. |
ISO | CL_ABAP_FORMAT=>D_ISO | The date if formatted in accordance with ISO 8601, using hyphens (-) as separators: "yyyy-mm-dd". |
USER | CL_ABAP_FORMAT=>D_USER | The date is formatted in accordance with the mask defined in the user master record. |
ENVIRONMENT | CL_ABAP_FORMAT=>D_ENVIRONMENT | The formatting of the date is determined |
according to the current formatting setting of the language environment that can be set using SET COUNTRY.
The default setting is RAW.
If the formatting setting of the
language environment has not been set to a
country-specific format by means of
SET COUNTRY, the use of environment has the same effect as the use of user.
See character string templates, formatting settings
The following string template creates the character string shown below it, depending on the current date.
2016-09-09
... TIME = RAW$|ISO$|USER$|ENVIRONMENT$|(dobj)$|expr ...
This formatting option defines the format of a time. The option TIME can be specified only if the embedded expression has the data type t.
The values for the format of the time specification are fixed. The following table shows the key words and the associated values from the class CL_ABAP_FORMAT that can be specified as dobj or expr:
Keyword | Value of dobj or expr | Effect |
RAW | CL_ABAP_FORMAT=>T_RAW | The content of the time field is passed without formatting. |
ISO | CL_ABAP_FORMAT=>T_ISO | The time is formatted in accordance with ISO 8601, in 24-hour format using colons (:) as separators: "hh:mm:ss". |
USER | CL_ABAP_FORMAT=>T_USER | The time is formatted in accordance with the format defined in the user master record. |
ENVIRONMENT | CL_ABAP_FORMAT=>T_ENVIRONMENT | The formatting of the time is determined |
according to the current formatting setting of the language environment that can be set using SET COUNTRY.
The default setting is RAW.
A 24-hour format and four 12-month formats can be set in the user master data or using the statement
SET COUNTRY. To use 12-hour format, USER or ENVIRONMENT must be specified or the formatting option COUNTRY used.
If the formatting setting of the
language environment has not been set to a
country-specific format by means of
SET COUNTRY, the use of environment has the same effect as the use of user.
See character string templates, formatting settings
The following string template creates the character string shown below it, depending on the current time, if a country with a 12-hour format is found in the DDIC database table T005X.
10:55:58 AM
... TIMESTAMP = SPACE$|ISO$|USER$|ENVIRONMENT$|(dobj)$|expr ...
This formatting option defines the format of a time stamp. The option TIMESTAMP can be specified only if the embedded expression is of one of the following data types, otherwise a syntax or runtime error occurs:
The values for the format of the time stamp are fixed. The following table shows the key words and the associated values from the class CL_ABAP_FORMAT that can be specified as dobj or expr:
Keyword | Value of dobj or expr | Effect |
SPACE | CL_ABAP_FORMAT=>TS_SPACE | The time stamp is represented according to the SQL standard ISO 9075, where there is a space between date and time, and a period (.) is used as a decimal separator: "yyyy-mm-dd hh:mm:ss.fffffff". |
ISO | CL_ABAP_FORMAT=>TS_ISO | The time stamp is represented according to ISO 8601 for date formats and time specifications, where the character "T" is between date and time and a comma (,) is used as the decimal separator: "yyyy-mm-ddThh:mm:ss,fffffff". |
USER | CL_ABAP_FORMAT=>TS_USER | As SPACE, but the date and time format, and the decimal separator are taken from the user master record. |
ENVIRONMENT | CL_ABAP_FORMAT=>TS_ENVIRONMENT | As SPACE. However, the date and time format, and the decimal separator are defined |
according to the current formatting setting of the language environment that can be set using SET COUNTRY.
- | CL_ABAP_FORMAT=>TS_RAW | The time stamp is formatted as an uninterrupted sequence of numbers without separators, except for a decimal separator (.) before fractions of seconds. |
The default setting is SPACE.
Initial values and invalid values are handled as follows:
The program DEMO_STRING_TEMPLATE_TIMESTAMP shows the use of the time stamp formats. Executing the program shows its effect. The following source text section is an excerpt from the program.
The following assignments show the use of the time stamp formats.
String Templates, Formatting Settings
... TIMEZONE = tz ...
This formatting option uses the rules for time zones to convert the date and time information of a time stamp into the local date and local time of the time zone specified in tz and formats the result as a time stamp. The option TIMEZONE can be specified only if the embedded expression has of one of the following data types, otherwise a syntax or runtime error occurs:
If the option TIMESTAMP is not specified, an expression of the type utclong is formatted according to its predefined format. A time stamp in a packed number is formatted in the same way as with the specification TIMESTAMP = SPACE. If the option TIMESTAMP is specified, it takes effect.
tz expects a character-like data object containing a time zone from the DDIC database table TTZZ. If the rule set for the specified time zone is incomplete, an uncatchable exception is raised. If tz is initial, no time shift is calculated. The conversion takes place as described in the statements CONVERT UTCLONG and CONVERT TIME STAMP. The special rules for the first and last second apply to the time stamp type utclong.
Initial values are handled as follows:
Error handling is as follows:
The program DEMO_STRING_TEMPLATE_TIMEZONE shows the use of the option TIMEZONE without using the option TIMESTAMP but also in connection with the option COUNTRY. Executing the program shows its effect.
The following assignments show the use of the option
TIMEZONE without using the option TIMESTAMP
but also in connection with the option COUNTRY.
... COUNTRY = cty ...
The formatting option COUNTRY defines a temporary formatting setting for the currently embedded expression. It can be specified as an alternative to all formatting options for which the parameter ENVIRONMENT can be specified (that is, instead of NUMBER, DATE, TIME, and TIMESTAMP). The embedded expression is formatted as a number, date, or time, or time stamp, depending on its data type.
cty expects a data object of the type LAND1 from the ABAP Dictionary that either contains a value from the LAND column of the DDIC database table T005X or is initial. If not, an exception of the class CX_SY_STRG_FORMAT is raised.
If cty contains a value from the data base table T005X, the country-specific format defined there is used. If cty is initial, the formatting specified in the user master record is used.
The following string template creates the character string shown below it, depending on the content of the DDIC database table T005X.
1,000,000
Leave us your contact details and we will call you back. Fields marked with * are mandatory.
We offer holistic SAP solutions from a single source to shape digital change and develop new business areas.
Switzerland
Schaffhausen
Germany
Mannheim, Düsseldorf, Munich
USA
Haverhill
Greece
Thessaloniki