SAP NetWeaver AS ABAP Release 740, ©Copyright 2014 SAP AG. All rights reserved.
ABAP Keyword Documentation → ABAP − Reference → Processing Internal Data → Character String and Byte String Processing → Statements for Character String and Byte String Processing →Syntax
TRANSLATE text {TO {UPPER|LOWER} CASE}
| {USING mask}.
Extras:
1. ... TO {UPPER|LOWER} CASE
2. ... USING mask
Effect
This statement converts the case or single characters of the character-type data object text.
CASE can be used to convert uppercase and lowercase letters; USING
can be used for conversion according to a pattern. The text variable must be character-type.
Note
There are two obsolete variants of this statement.
... TO {UPPER|LOWER} CASE
Effect
If UPPER is specified, all lowercase letters of the data object text are converted to uppercase. If LOWER is specified, all uppercase letters are converted to lowercase.
Notes
Example
After the conversion, the variable text contains "CAREFUL WITH THAT AXE, EUGENE".
DATA text TYPE string.
text = `Careful with that Axe, Eugene`.
TRANSLATE text TO UPPER CASE.
... USING mask
Effect
If USING is specified, the characters in text are converted according to the rule specified in the data object mask. mask is a character-like expression position whose value is interpreted as a string of character pairs. A search is performed in text, beginning with the first pair, for the first character in every pair. Every instance is found is replaced with the second character of the pair. The search is case-sensitive. If text contains a character multiple times as the first character of a pair, only the first pair is taken into account. A character in text that has already been replaced cannot be replaced again in the same TRANSLATE statement. Therefore, if the second character of a pair in mask appears as the first character of a subsequent pair, the second pair affects only the original characters in text.
Trailing blanks in data objects text and mask are taken into account for data objects. If mask contains an uneven number of characters, the last character is ignored. If mask is a blank string, no replacements take place.
Note
To translate a character string in an operand position, a
translate function that includes the functions of the statement TRANSLATE can also be used.
Example
Conversion of the characters "A" to "B", "a" to "b" and the other way round. After implementation, text contains "Abracadabra".
DATA text TYPE string.
text = `Barbcbdbarb`.
TRANSLATE text USING 'ABBAabba'.