Skip to content

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

  1. ... to_upper( [val =] text ) ...

  2. ... to_lower( [val =] text ) ...

  3. ... to_mixed( [val =] text [sep = sep] [case = case] [min = min] ) ...

  4. ... 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_upper converts all letters in the character string to uppercase letters.
  • The function to_lower converts all letters in the character string to lowercase letters.
  • The function to_mixed converts all letters in the character string to lowercase letters from the second position. It then removes occurrences of the first character specified in sep from the character string (from left to right from the second position) and converts the next letter to an uppercase letter. The default value for separator sep is an underscore (_). If case is not specified, the first character of the string remains unchanged. If case is specified and the first character of case is 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 to min 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 for min 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 separator sep is an underscore (_). If case is not specified or if the first character in case is an uppercase letter, the entire string is displayed as uppercase; otherwise it is displayed as lowercase. You can pass a positive number to min 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 for min is 1.

sep is a character-like expression position. If they have a fixed length, trailing blanks are ignored. min is a numerical expression position. 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_mixed and from_mixed are 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 LOCALE statement before the conversion takes place.

Exceptions


Catchable Exceptions

CX_SY_STRG_PAR_VAL

  • Cause: The separator in sep is empty or the minimum number in min is negative.
    Runtime Error: STRG_ILLEGAL_PAR