Converting to Upper or Lower Case or Replacing Characters 

The TRANSLATE statement converts characters into upper or lower case, or uses substitution rules to convert all occurrences of one character to another character.

Converting to Upper or Lower Case

TRANSLATE <c> TO UPPER CASE.

TRANSLATE <c> TO LOWER CASE.

These statements convert all lower case letters in the field <c> to upper case or vice versa.

Substituting Characters

TRANSLATE <c> USING <r>.

This statement replaces all characters in field <c> according to the substitution rule stored in field <r> . <r> contains pairs of letters, where the first letter of each pair is replaced by the second letter. <r> can be a variable.

For more variants of the TRANSLATE statement with more complex substitution rules, see the keyword documentation in the ABAP Editor.

DATA: T(10) VALUE 'AbCdEfGhIj',
STRING LIKE T,
RULE(20) VALUE 'AxbXCydYEzfZ'.

STRING = T.
WRITE STRING.

TRANSLATE STRING TO UPPER CASE.
WRITE / STRING.

STRING = T.
TRANSLATE STRING TO LOWER CASE.
WRITE / STRING.

STRING = T.
TRANSLATE STRING USING RULE.
WRITE / STRING.

Output:

AbCdEfGhIj

ABCDEFGHIJ

abcdefghij

xXyYzZGhIj