The TRANSLATE statement converts characters into upper or lower case, or uses substitution rules to convert all occurrences of one character to another character.
TRANSLATE text TO UPPER CASE.
TRANSLATE text TO LOWER CASE.
These statements convert all lower case letters in the field <c> to upper case or vice versa.
TRANSLATE text USING pattern.
This statement replaces all characters in the text field according to the substitution rule stored in pattern. pattern contains letter pairs where the first letter of each pair is replaced by the second. pattern can be a variable.
For more variants of the TRANSLATE statement with more complex substitution rules (obsolete variants!), refer to the keyword documentation.
DATA:
t(10) TYPE c VALUE 'AbCdEfGhIj',
string LIKE t,
rule(20) TYPE c 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