TRANSLATE
Short Reference
ABAP Syntax TRANSLATE text {TO {UPPER|LOWER} CASE}
| {USING mask}.
ABAP_ADDITIONS:
1 ... TO {UPPER|LOWER} CASE
2 ... USING mask
What does it do? 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.
Latest notes: There are two obsolete variants
of this statement.
ABAP_ADDITION_1 ... TO {UPPER|LOWER} CASE
What does it do? 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.
Latest notes: In non-Unicode systems, the conversion of the case depends
on the text environment . Problems
can arise if the language of the text environment is different to the
language in which the data to be processed has been entered. To avoid
these kinds of problems, the text environment must be configured
accordingly using the SET LOCALE statement
before the conversion takes place.
To modify the case of the letters in a character string in an operand
position, a case function can be used that
includes the functions of the statement TRANSLATE .
Example ABAP Coding 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.
ABAP_ADDITION_2 ... USING mask
What does it do? 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.
Latest notes: 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 ABAP Coding 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'.
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved