How to: |
Available Languages: reporting
The UPCASE function converts a character string to uppercase. It is useful for sorting on a field that contains both mixed-case and uppercase values. Sorting on a mixed-case field produces incorrect results because the sorting sequence in EBCDIC always places lowercase letters before uppercase letters, while the ASCII sorting sequence always places uppercase letters before lowercase. To obtain correct results, define a new field with all of the values in uppercase, and sort on that field.
There is a version of the UPCASE function that is available only in the Maintain language. For information on this function, see UPCASE: Converting Text to Uppercase (Maintain).
UPCASE(length, source_string, output)
where:
Integer
Is the number of characters in source_string and output.
Alphanumeric
Is the string to convert enclosed in single quotation marks, or the field containing the character string.
Alphanumeric of type AnV or An
Is the field to which the result is returned, or the format of the output value enclosed in single quotation marks.
UPCASE converts the LAST_NAME_MIXED field to uppercase:
DEFINE FILE EMPLOYEE LAST_NAME_MIXED/A15=IF DEPARTMENT EQ 'MIS' THEN LAST_NAME ELSE LCWORD(15, LAST_NAME, 'A15'); LAST_NAME_UPPER/A15=UPCASE(15, LAST_NAME_MIXED, 'A15') ; END
TABLE FILE EMPLOYEE PRINT LAST_NAME_MIXED AND FIRST_NAME BY LAST_NAME_UPPER WHERE CURR_JOBCODE EQ 'B02' OR 'A17' OR 'B04'; END
Now, when you execute the request, the names are sorted correctly.
The output is:
LAST_NAME_UPPER LAST_NAME_MIXED FIRST_NAME --------------- --------------- ---------- BANNING Banning JOHN BLACKWOOD BLACKWOOD ROSEMARIE CROSS CROSS BARBARA MCCOY MCCOY JOHN MCKNIGHT Mcknight ROGER ROMANS Romans ANTHONY
If you do not want to see the field with all uppercase values, you can NOPRINT it.