How to: |
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.
In FIDEL, CRTFORM LOWER retains the case of entries exactly as they were typed. Use UPCASE to convert entries for particular fields to uppercase.
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.
Suppose your company decides to store employee names in mixed case and the department assignments in uppercase.
To enter records for new employees, execute this MODIFY procedure:
MODIFY FILE EMPLOYEE CRTFORM LOWER "ENTER EMPLOYEE'S ID : <EMP_ID" "ENTER LAST_NAME: <LAST_NAME FIRST_NAME: <FIRST_NAME" "TYPE THE NAME EXACTLY AS YOU SEE IT ON THE SHEET" " " "ENTER DEPARTMENT ASSIGNMENT: <DEPARTMENT" MATCH EMP_ID ON MATCH REJECT ON NOMATCH COMPUTE DEPARTMENT = UPCASE(10, DEPARTMENT, 'A10'); ON NOMATCH INCLUDE ON NOMATCH TYPE "DEPARTMENT VALUE CHANGED TO UPPERCASE: <DEPARTMENT" DATA END
The procedure processes as:
ENTER EMPLOYEE'S ID : 444555666 ENTER LAST_NAME: Cutter FIRST_NAME: Alan TYPE THE NAME EXACTLY AS YOU SEE IT ON THE SHEET ENTER DEPARTMENT ASSIGNMENT: sales
ENTER EMPLOYEE'S ID : ENTER LAST_NAME: FIRST_NAME: TYPE THE NAME EXACTLY AS YOU SEE IT ON THE SHEET ENTER DEPARTMENT ASSIGNMENT: DEPARTMENT VALUE CHANGED TO UPPERCASE: SALES
TRANSACTIONS: TOTAL = 1 ACCEPTED= 1 REJECTED= 0
SEGMENTS: INPUT = 1 UPDATED = 0 DELETED = 0