Text symbols are special text constants that you enter and maintain independently of the program code. In the final versions of your programs, you should use text symbols instead of hard-coded texts. This makes the programs language-independent and easier to maintain.
For further information about literals and text symbols, refer to
literals and text symbols in the ABAP User's Guide.Prerequisites
You must assign a three-character ID to each text symbol. You define this in the WRITE statement as follows:
WRITE... TEXT-<idt>...
When you run the program, the system searches in the text pool for a text symbol with the ID <idt> and displays it. If it does not find text symbol <idt>, it ignores that part of the WRITE statement.
The ID may not begin '%_', and may not contain spaces.
The rest of this section is based on the following coding example:
PROGRAM TEXT_ELEMENTS_2.
WRITE: TEXT-010,
/ TEXT-AAA,
/ TEXT-020,
/ 'Default Text 030'(030),
/ 'Default Text 040'(040).
Procedure
From the ABAP Editor:
Result
The text symbol is included in the text pool in the relevant language. You can now carry on and create other text symbols, or change existing ones.
Other Functions
Creating Further Text Symbols
Spaces in text symbols are no longer represented by underscores. This means that you can now output underscores as characters in a text symbol.
Using Text Symbols with Text Literals
You can link a text symbol to a text literal as follows:
WRITE... '<textliteral>'(<idt>)...
If the text symbol <idt> exists, the system uses it. If it does not exist, the system uses the text literal <textliteral>.
For an example, see above.
If we did not create text symbols with the IDs "020" and "040" in the above example, the system would display the following:
Here, the system ignores the WRITE statement for the missing text symbol 020, and uses the default text (defined as a literal in the WRITE statement) for text symbol 040, since there is no text symbol defined for it in the text pool.
Deleting Text Symbols
To delete a text symbol, select the appropriate line and choose Delete.