%LOWER built-in function

The %LOWER built-in function returns a character string that is the same length as the argument specified with each uppercase letter replaced by the corresponding lowercase letter.

The %LOWER built-in function can be used anywhere that CL supports a character expression. %LOWER can be used alone or as part of a more complex character expression. For example, %LOWER can be used to convert character CL variables to have only lower case characters before comparing them in the COND parameter of an IF or WHEN command. %LOWER can also be used to set the value of a CL command parameter, if the associated command object defines the parameter with EXPR(*YES) and TYPE of *CHAR, *NAME, *SNAME, *CNAME, *PNAME, *GENERIC, *DATE, *TIME, or *X.

The format of the convert to lowercase built-in function is:
%LOWER(input-string [CCSID])

The input-string must be a CL variable with TYPE of *CHAR.

The CCSID parameter is optional and defaults to the job CCSID. The CCSID specifies the coded character set identifier (CCSID) of the input string to be converted. Case conversion is performed based on this CCSID. The CCSID, if specified, must be a CL integer variable or a CL decimal variable with zero decimal positions or a numeric literal with zero decimal positions. The valid values are:
  • 0: The CCSID of the job is used to determine the CCSID of the data to be converted. If the job CCSID is 65535, the CCSID from the default CCSID (DFTCCSID) job attribute is used.
  • 1-65533: A valid CCSID in this range.

The following are examples of using the %LOWER built-in function:

  • Convert to lowercase
    DCL VAR(&STR) TYPE(*CHAR) LEN(12) VALUE('Hello World!')
    /* 'hello world!' is to be sent */
    SNDPGMMSG (%LOWER(&STR))
  • Convert to lowercase based on CCSID
    /* define &STR as 'Hello World!' in CCSID 819 (ISO/ANSI Multilingual) */
    DCL VAR(&STR) TYPE(*CHAR) LEN(12) + 
                  VALUE(X'48656C6C6F20576F726C6421')
    /* &STR will have the value x'68656C6C6F20776F726C6421' ('hello world!') */
    CHGVAR VAR(&STR) VALUE(%LOWER(&STR 819))