ABAP Keyword Documentation → ABAP − Reference → Processing Internal Data → Character String and Byte String Processing → Character and Byte String Processing - Overview
Trailing Blanks in Character String Processing
Statements for character string processing generally preserve leading blanks for operands of data types with fixed lengths
(c
, n
, d
, and
t or character-like structures) and cut off trailing blanks. Exceptions to this rule are explained
in the affected statements. All blanks are generally preserved for operands of the data type string
.
If the result of a statement for character string processing is assigned to an operand, the operand is generally padded on the right with blanks if the result is shorter than the length of the operand. String assignments generally adapt the string length to the length of the result. Exceptions to this rule are explained in the affected statements.
Other versions: 7.31 | 7.40 | 7.54
Programming Guideline
Do not use trailing blanks in text field literals
Notes
- The cutting off of trailing blanks especially affects the
text field literal '
' and the constant
space
. These should therefore never be executed at operand positions where trailing blanks are truncated.
- In long results fields, padding with blanks can produce invalid values, if the fields have the type
n
,d
, ort
.
- The preservation of trailing blanks can be forced for assignments by using the addition RESPECTING
BLANKS of the statement
CONCATENATE
.
Example
The result of the following concatenation is a string with exactly one blank. The blank characters in space
and '
' are ignored. At operand positions after SEPARATED BY
however, the
blank character which is contained explicitly in ''
is not ignored. If the addition RESPECTING BLANKS
is used, the result is a string with three blanks.
DATA text TYPE string.
CONCATENATE space ' ' INTO text SEPARATED BY ''.