%UPPER built-in function
The %UPPER built-in function returns a character string that is the same length as the argument specified with each lowercase letter replaced by the corresponding uppercase letter.
The %UPPER built-in function can be used anywhere that CL supports a character expression. %UPPER can be used alone or as part of a more complex character expression. For example, %UPPER can be used to convert character CL variables to have only upper case characters before comparing them in the COND parameter of an IF or WHEN command. %UPPER 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.
%UPPER(input-string [CCSID])
The input-string must be a CL variable with TYPE of *CHAR.
- 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 %UPPER built-in function:
- Convert to uppercase
DCL VAR(&STR) TYPE(*CHAR) LEN(12) VALUE('Hello World!') /* 'HELLO WORLD!' is to be sent */ SNDPGMMSG (%UPPER(&STR))
- Convert to uppercase 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'48454C4C4F20574F524C4421' ('HELLO WORLD!') */ CHGVAR VAR(&STR) VALUE(%UPPER(&STR 819))