SAP STRING PROCESSING TRAIL BLANKS



Get Example source ABAP code based on a different SAP table
  



Trailing Blanks in Character String Processing
There is a major difference between data types of fixed length and text strings regarding the treatment of blanks:
All blanks are generally preserved in operations with operands of the data type string.
In assignments and statements for character string processing, leading blanks for operands of data types with fixed lengths (c, n , d, and t or character-like structures) are generally preserved and trailing blanks are truncated. Exceptions to this rule are explained in the affected statements.
If the result of a statement for character string processing is assigned to an operand, it is generally padded on the right with blanks if the result is shorter than the length of the operand. Assignments to a string generally adapt the string length to the length of the result. Exceptions to this rule are explained in the affected statements.

ABAP_PGL
Do not use trailing blanks in text field literals
ABAP_PGL_END



Latest notes:

Truncating trailing blanks especially affects the text field literal ' ' and the constant space. These should therefore never be listed in operand positions where trailing blanks are truncated.
In result fields that are too long, padding with blanks can produce invalid values, if the fields have the type n, d, or t .
The preservation of trailing blanks can be forced for assignments using the addition RESPECTING BLANKS of the statement CONCATENATE.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
The result of the following concatenation is a string with exactly one blank. The blank characters in space and ' ' are ignored. At the operand position after SEPARATED BY however, the blank character that is contained explicitly in '' is not ignored. If the addition RESPECTING BLANKS was used, the result would be a string with three blanks.
ABEXA 01306
ABAP_EXAMPLE_END