SAP TRAILING BLANKS LITERALS - Guide
Get Example source ABAP code based on a different SAP table
Trailing Blanks in Character Literals
ABAP_BACKGROUND
Trailing blanks in text field literals use memory, but are
ABAP_RULE
They should also not be specified in literals in any operand positions where trailing blanks are not relevant.
ABAP_DETAILS
This rule is designed mainly to make programs more readable. It makes no sense to specify literal characters in places where they are ignored, and raises expectations in users of the program that cannot be met. In particular, this also applies to the text field literal
Conversely, specifying the supposedly empty text field literal
ABAP_EXAMPLE_BAD
The following simple example demonstrates the full scope of the rule. Any readers with little experience in ABAP would expect the result of the assignment to be a string with length six. In actual fact, the result contains only the three relevant places.
ABEXA 01358
ABAP_EXAMPLE_END
ABAP_EXAMPLE_GOOD
Whether the example needs to be improved depends on whether the trailing blanks are required. If the blanks are needed, use a text string literal:
If they are not needed, leave them out:
ABAP_EXAMPLE_END
ABAP_EXAMPLE_BAD
The following example demonstrates that the supposedly empty literal
ABEXA 01359
ABAP_EXAMPLE_END
ABAP_EXAMPLE_GOOD
Depending on whether the blank is needed as a separator, either
ABAP_EXAMPLE_END