SAP COMPUTE STRING FORMAT OPTIONS ABAP Statements



Get Example source ABAP code based on a different SAP table
  


• WIDTH ABAP_STRING_TEMPL
• ALIGN ABAP_STRING_TEMPL
• LEFT ABAP_STRING_TEMPL
• RIGHT ABAP_STRING_TEMPL
• CENTER ABAP_STRING_TEMPL
• PAD ABAP_STRING_TEMPL
• CASE ABAP_STRING_TEMPL
• RAW ABAP_STRING_TEMPL
• UPPER ABAP_STRING_TEMPL
• LOWER ABAP_STRING_TEMPL
• SIGN ABAP_STRING_TEMPL
• LEFTPLUS ABAP_STRING_TEMPL
• LEFTSPACE ABAP_STRING_TEMPL
• RIGHTPLUS ABAP_STRING_TEMPL
• RIGHTSPACE ABAP_STRING_TEMPL
• EXPONENT ABAP_STRING_TEMPL
• DECIMALS ABAP_STRING_TEMPL
• XSD ABAP_STRING_TEMPL
• ZERO ABAP_STRING_TEMPL
• YES ABAP_STRING_TEMPL
• NO ABAP_STRING_TEMPL
• NUMBER ABAP_STRING_TEMPL
• USER ABAP_STRING_TEMPL
• ENVIRONMENT ABAP_STRING_TEMPL
• COUNTRY ABAP_STRING_TEMPL
• STYLE ABAP_STRING_TEMPL
• CURRENCY ABAP_STRING_TEMPL
• ALPHA ABAP_STRING_TEMPL
• DATE ABAP_STRING_TEMPL
• ISO ABAP_STRING_TEMPL
• TIME ABAP_STRING_TEMPL
• TIMESTAMP ABAP_STRING_TEMPL
• SPACE ABAP_STRING_TEMPL
• TIMEZONE ABAP_STRING_TEMPL

ABAP_EMBDEXP - format_options

ABAP_SYNTAX
... $[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$] ...

ABAP Addition
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 ...

What does it do?
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:
Statically as a key word
Dynamically as
the content of a data object (dobj) specified in parentheses
result of a functional method or method chaining, a constructor expression, or a table expression expr The possible values of dobj or expr are defined as constants in the class CL_ABAP_FORMAT .
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.



Latest notes:

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.
NON_V5_HINTS
ABAP_HINT_END

ABAP Addition

What does it do?
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.

ABAP_EXAMPLE_VX5
The length of the result of the following string template is 20. It consists of 4 digits, a decimal separator, and 15 trailing blanks.
ABEXA 00121
ABAP_EXAMPLE_END

ABAP_EXAMPLE_ABEXA
String Templates, Length
ABAP_EXAMPLE_END

ABAP Addition

What does it do?
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: KeywordValue of dobj or exprEffect LEFTCL_ABAP_FORMAT=>A_LEFTLeft-aligned RIGHTCL_ABAP_FORMAT=>A_RIGHTRight-aligned CENTERCL_ABAP_FORMAT=>A_CENTERCentered
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.

ABAP_EXAMPLE_VX5
The following string template creates the character string shown below it.
ABEXA 00122 1 2 3 < -
ABAP_EXAMPLE_END

ABAP_EXAMPLE_ABEXA
String Templates, Alignments and Padding
ABAP_EXAMPLE_END

ABAP Addition

What does it do?
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.

ABAP_EXAMPLE_VX5
The following string template creates the character string shown below it.
ABEXA 00123 _________X
ABAP_EXAMPLE_END

ABAP_EXAMPLE_VX5
See String Templates, Alignments and Padding
ABAP_EXAMPLE_END

ABAP Addition

What does it do?
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: KeywordValue of dobj or exprEffect RAWCL_ABAP_FORMAT=>C_RAWUnchanged UPPERCL_ABAP_FORMAT=>C_UPPERUppercase LOWERCL_ABAP_FORMAT=>C_LOWERLowercase
The default setting is RAW.



Latest notes:

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.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
The following string template creates the character string shown below it.
ABEXA 00124 48656c6c6f20576f726c6421
ABAP_EXAMPLE_END

ABAP_EXAMPLE_ABEXA
String Templates, Case
ABAP_EXAMPLE_END

ABAP Addition LEFT$|LEFTPLUS$|LEFTSPACE$|RIGHT$|RIGHTPLUS$|RIGHTSPACE$|(dobj)$|expr ...

What does it do?
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 : KeywordValue of dobj or exprEffect LEFTCL_ABAP_FORMAT=>S_LEFT- left without space, no + LEFTPLUSCL_ABAP_FORMAT=>S_LEFTPLUS- and + left without space LEFTSPACECL_ABAP_FORMAT=>S_LEFTSPACE- left without space, blank left for + RIGHTCL_ABAP_FORMAT=>S_RIGHT- right without space, no + RIGHTPLUSCL_ABAP_FORMAT=>S_RIGHTPLUS- and + right without space RIGHTSPACECL_ABAP_FORMAT=>S_RIGHTSPACE- left without space, blank right for +
The default setting is LEFT.

ABAP_EXAMPLE_VX5
The following string template creates the character string shown below it.
ABEXA 00125 +1
ABAP_EXAMPLE_END

ABAP_EXAMPLE_ABEXA
String Templates, Sign
ABAP_EXAMPLE_END

ABAP Addition

What does it do?
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.