Text Symbols

Text symbols are text constants which you enter and maintain outside a program. You should use text symbols instead of text literals in the final version of your program to keep it language-independent and easy to maintain.

Maintaining Text Symbols

To create or change text symbols, select Text symbols on the ABAP Text Elements screen and choose Change.

For each text symbol, you must specify a three-character identifier which contains no blanks and does not begin with the character ‘% ‘. You can assign a text of up to 132 characters to each text symbol.

You specify the three-character identifier in column Sym and the text in column Text.

Starting with Release 3.1g, blanks are not represented by underscores (_) any more and you can output underscores to the screen using text symbols.

Column dLen shows the actual length of the text. You can define the maximum length in column mLen. A language key in column L. shows that there is no text symbol defined for the current logon language but for the original language. The language key shows the original language of the program (see example in Translating Text Elements).

You can use the functions of the Edit menu to format text symbols.

To delete a text symbol, mark the line with the text symbol and choose Delete.

Save your changes by choosing Save.

Using Text Symbols in ABAP Programs

You use text symbols exactly as literals in your ABAP programs. With other words, at each position in a statement where you can write a literal, you can write also a text symbol. To do so, you use the following syntax for the text symbol:

Syntax

... TEXT-<idt>...

The system searches in the text pool for a text symbol with the identifier <idt> and treats TEXT-<idt> in the statement like literal that contains the text of the text symbol. If the text symbol <idt> does not exist in the text pool, the system treats TEXT-<idt> like the constant SPACE.

To avoid the use of SPACE, you can define a literal in your program that the system can use instead. To do this, use the following syntax:

Syntax

... '<text>'(<idt>)...

If a text symbol <idt> exists in the text pool, the system uses the text symbol instead of the literal '<text>'. Otherwise, it uses the literal <text>.

The ABAP Development Workbench supports you in creating text symbols as follows:

  1. Type your statements with literals in the ABAP Editor.
  2. Select the literals by double-clicking with the mouse.
  3. The system creates automatically a text symbol with the contents of the literal and navigates to the maintenance of that text symbol. The entries in the columns dLen and mLen correspond initially to the length of the literal. You can change mLen when maintaining the text symbols.

  4. Change the text symbol if necessary and navigate back to the ABAP Editor.

The system has then automatically included the number <idt> in parentheses behind the literal. Your program will use the text symbol and not the literal when executing the program.

The following example shows the use of text symbols in WRITE statements. Remember, that you can use text symbols in other statements, for example for value assignments, as well.

PROGRAM SAPMZTST.

WRITE:   TEXT-010,
/ TEXT-AAA,
/ TEXT-020,
/ 'Default Text 030'(030),
/ 'Default Text 040'(040).

If the text symbols of the above screen shots are linked to this program, the output looks as follows:

The text symbols 020 and 040 do not exist. In the case of 020, the WRITE statement puts out SPACE to the list. The blank literal is not shown since the system by default suppresses blank lines (see Inserting Blank Lines). In the case of 040, the text defined in the program is output to the screen.