UPPER and UCASE functions

UPPER and UCASE are equivalent string manipulation functions that manipulate CHARACTER string data and convert lowercase characters in a string to uppercase.

Syntax

Read syntax diagramSkip visual syntax diagram UPPERUCASE (source_string)

UPPER and UCASE both return a new character string, which is identical to source_string, except that all lowercase letters are replaced with the corresponding uppercase letters.

For example:
UPPER('ABCD')
returns 'ABCD'.
UCASE('abc123')
returns 'ABC123'.
Converting characters from different code pages to uppercase

If you are using certain code pages, characters with no uppercase equivalent in your code page might be converted when you use the UPPER or UCASE function. This conversion happens because the bit stream is converted to a Unicode message tree by the message parser. Even though characters might have no uppercase equivalent in the source code page, they can still have an uppercase equivalent in the Unicode code page, and are converted by the UPPER or UCASE function. When the bit stream is converted back to the original code page, these characters cannot be converted back, and a substitution character is inserted into the output message for each character. The substitution character inserted depends on the original code page. For example, conversion to an EBCDIC code page inserts an X'3F' byte and conversion to a Japanese code page inserts an X'7F' byte.

A solution to this problem is to use the TRANSLATE function to convert selected characters to uppercase, instead of using the UPPER or UCASE function. Any characters that have no uppercase equivalent in the code page are excluded from the conversion.

In the following example, the input message is in code page 284, and the InputRoot.XML.MSG.APPDATA element contains characters that do not have an uppercase equivalent in code page 284, but do have uppercase equivalents in the Unicode code page. The TRANSLATE function is used to convert only the lowercase characters 'a' to 'z' to their equivalent uppercase characters. Any other characters in InputRoot.XML.MSG.APPDATA are excluded from the conversion.
DECLARE char1 CHAR;
SET char1 = TRANSLATE(InputRoot.XML.MSG.APPDATA,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ');
SET OutputRoot.MQMD.CodedCharSetId = 284;
SET OutputRoot.XML.TEST.translated = char1;