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 in accordance with the following case rules:
- The function
to_upper
transforms all letters in the character string to uppercase letters.
- The function
to_lower
transforms all letters in the character string to lowercase letters.
- The function
to_mixed
transforms all letters in the character string to lowercase letters from the second position. It then removes occurrences of the first character specified insep
from the character string (from left to right from the second position) and transforms the next letter to an uppercase letter. The default value for separatorsep
is an underscore (_
). Ifcase
is not specified, the first character of the string remains unchanged. Ifcase
is specified and the first character ofcase
is an uppercase letter, the first character in the string is also uppercase and then lowercase in all other occurrences. A positive number can be passed tomin
to 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 formin
is 1.
- The function
from_mixed
inserts the first character specified in sep before each uppercase letter (from left to right and from the second position). The default value for separatorsep
is an underscore (_
). Ifcase
is not specified or if the first character incase
is an uppercase letter, the entire string is displayed as uppercase; otherwise it is displayed as lowercase. A positive number can be passed tomin
to 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 formin
is 1.
sep
is a
character-like expression position. If they have a fixed length, trailing blanks are ignored. min
is a
numeric expression
position of type i
. case
expects a character-like data object with a fixed length. val
= can be omitted 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.
Note
The functions to_mixed
and from_mixed
are used
to transform standard ABAP naming conventions for names with underscores to standard Java naming conventions
with uppercase and lowercase letters and (namely Mixed Case Style and Camel Case Style) and the other way around.
Example
Outputs the Latin alphabet in lowercase letters.
cl_demo_output=>display( to_lower( sy-abcde ) ).
Executable Example
String Functions, to_mixed
and from_mixed
Exceptions
Handleable Exceptions
CX_SY_STRG_PAR_VAL
-
Cause: The separator in
sep
is empty or the minimum number inmin
is negative.
Runtime error:STRG_ILLEGAL_PAR