ABAP Keyword Documentation → ABAP - Reference → Processing Internal Data → Character String and Byte String Processing → Expressions and Functions for String Processing → String Functions → Processing Functions for Character-Like Arguments
to_upper, to_lower, to_mixed, from_mixed - Case Functions
Other versions: 7.31 | 7.40 | 7.54
Syntax Forms
-
... to_upper( [val =] text ) ... -
... to_lower( [val =] text ) ... -
... to_mixed( [val =] text [sep = sep] [case = case] [min = min] ) ... -
... from_mixed( [val =] text [sep = sep] [case = case] [min = min] ) ...
Effect
These functions return the character string from text after it has been converted according to the following case rules:
- The function
to_upperconverts all letters in the character string to uppercase letters.
- The function
to_lowerconverts all letters in the character string to lowercase letters.
- The function
to_mixedconverts all letters in the character string to lowercase letters from the second position. It then removes occurrences of the first character specified insepfrom the character string (from left to right from the second position) and converts the next letter to an uppercase letter. The default value for separatorsepis an underscore (_). Ifcaseis not specified, the first character of the string remains unchanged. Ifcaseis specified and the first character ofcaseis an uppercase letter, the first character in the string is also uppercase and then lowercase in all other occurrences. You can pass a positive number tominto specify a minimum number of characters that must appear before a separator (from the start of the string or since the last replacement) before the separator becomes effective. The default value forminis 1.
- The function
from_mixedinserts the first character specified in sep before each uppercase letter (from left to right and from the second position). The default value for separatorsepis an underscore (_). Ifcaseis not specified or if the first character incaseis an uppercase letter, the entire string is displayed as uppercase; otherwise it is displayed as lowercase. You can pass a positive number tominto specify a minimum number of characters that must appear before an uppercase letter (from the start of the string or since the last insert) so that a separator is inserted. The default value forminis 1.
sep is a
character-like expression position. If they have a fixed length, trailing blanks are ignored. min is a
numerical expression
position of type i. case expects a character-like data object with a fixed length. You can omit val
= only if none of the optional arguments are specified. If sep is an empty string or if min is negative, an exception of class CX_SY_STRG_PAR_VAL is raised.
The return code has the type string accordingly.
Notes
-
The functions
to_mixedandfrom_mixedare used to convert standard ABAP naming conventions for labels with underscores to standard Java naming conventions with uppercase and lowercase letters and the other way around. -
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 LOCALEstatement before the conversion takes place.
Example
Exceptions
Catchable Exceptions
CX_SY_STRG_PAR_VAL
-
Cause: The separator in
sepis empty or the minimum number inminis negative.
Runtime Error:STRG_ILLEGAL_PAR