Search code examples
charabapspace

Add space at end of a constant char in ABAP


I need to declare this constant:

CONSTANTS: const_sep(3) type c value ' - '.

but with this command, ending space is not considered. How can I declare this constant value?


Solution

  • Short version: You don't. When working with fields of TYPE C (which are always fixed-length fields), the system always trims trailing whitespace. Switch to a TYPE STRING if you need to keep the trailing whitespace, and use the correct delimiters for strings:

    CONSTANTS co_sep TYPE string VALUE ` - `.
                                 "     ^   ^