ABAP Keyword Documentation → ABAP − Reference → Processing Internal Data → Character String and Byte String Processing → Expressions and Functions for String Processing → string_exp - String Expressions → string_exp - String Templates → String Templates - embedded_expressions
Embedded Expressions - Predefined Formats
The following predefined formatting rules apply to embedded expressions in string templates. These rules
can be overridden by explicit formatting options format_options
.
Other versions: 7.31 | 7.40 | 7.54
Text Length
The predefined text length is the minimum length required to represent the whole result of the embedded expression.
Note
The predefined text length can be overridden using the formatting option WIDTH
.
Example
The length of the result of the following string template is 5. It consists of 4 digits and a decimal separator.
DATA(text) = |{ CONV decfloat34( 1234 / 10 ) }|.
Alignment
The predefined alignment for all data types is left-aligned.
Note
The predefined alignment can be overridden using the formatting option ALIGN
.
Example
The following string template creates the character string shown below it.
DATA(text) = |{ 1 WIDTH = 5 }{ 2 WIDTH = 5 }{ 3 WIDTH = 5 }<-|.
Character-Like Data Types and Date/Time Types
For character-like data types with fixed lengths (c
and n
) and the date/time types
(d
, t
), the full content is used and any trailing blanks ignored. The content of text strings with the type string
is used in full.
Note
Unlike in WRITE TO
, no formatting is applied to the data types d
and t
(unless
formatting options are specified explicitly) and no separators are inserted.
Example
The following string template generates the character string shown below (depending on the date and time). The format is independent of the formatting settings.
DATA(text) = |{ sy-datlo } { sy-timlo }| .
Byte-Like Data Types
Values of the byte-like data types x
and xstring
are formatted in hexadecimal format, where a byte is represented by two characters.
Example
The following string template creates the character string shown below it.
DATA(text) =
|{ cl_abap_conv_codepage=>create_out( )->convert( 'Hello World!' ) }|.
Numeric Data Types
The following rules apply to the representation of numeric values:
- For negative values, the minus sign is placed on the left of the number, without a blank. No sign is placed in front of positive numbers by default.
- The period (
.
) is always used as the decimal separator.
- No thousand separators are inserted.
The following applies to the individual numeric data types:
- When formatting values of data type (
b
,s
),i
,int8
, andp
, all decimal places are taken into consideration in mathematical notation.
- Values with the data types
decfloat16
anddecfloat34
are formatted by default in mathematical notation, without an exponent. The formatting option EXPONENT can be used to represent the exponent. Trailing zeroes in decimal places are not usually displayed. The formatting optionDECIMALS
can be used to display the required number of decimal places.
- Values with the data type
f
are formatted by default in mathematical notation, without an exponent. The formatting option EXPONENT can be used to represent the exponent. Trailing zeroes in decimal places are not usually displayed. The formatting optionDECIMALS
can be used to display the required number of decimal places.
Example
The following string template generates the string below, with a platform-dependent result for the data type f
. If the
conversion operator is not specified, the
calculation type of the embedded expression is i
.
DATA(text) = |{ - 2 / 3 }, {
CONV decfloat34( - 2 / 3 ) }, {
CONV f( - 2 / 3 ) }|.
Time Stamp Type
A valid time stamp in a
time stamp field with the
time stamp type utclong
is formatted as
"yyyy-mm-dd hh:mm:ss.fffffff" in accordance with SQL standard ISO 9075. A blank is placed between the date and time and the period
(.) is used as the default decimal separator. An initial time stamp field
is represented by a string of 27 blanks. A time stamp field whose value is greater than or equal to
the last second or is between "9999-12-31 23:59:59.0000000" and
"9999-12-31 23:59:59.9999999" is represented as "9999-12-31 23:59:59.9999999".
This setting can be overwritten using formatting options like
TIMESTAMP
,
COUNTRY, or DECIMALS
.
Example
The following string template creates the character string shown below it.
DATA(text) = |{ utclong_add( val = VALUE utclong( )
days = CONV #( CONV d( '20190402' ) )
hours = 10
minutes = 30
seconds = CONV #( '12.3456789' ) ) }|.