UPCASE: Converting Text to Uppercase

Available Operating Systems: All

Available Languages: reporting

How to:

Convert Text to Uppercase

Example:

Converting a Mixed Case Field to Uppercase

Converting a Lowercase Field to Uppercase With MODIFY

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.

In FIDEL, CRTFORM LOWER retains the case of entries exactly as they were typed. Use UPCASE to convert entries for particular fields to uppercase.

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).


Top of page

Syntax: How to Convert Text to Uppercase

UPCASE(length, input, outfield)

where:

length

Integer

Is the length in characters of input and outfield.

input

Alphanumeric

Is the character string enclosed in single quotation marks, or the field containing the character string.

outfield

Alphanumeric

Is the field to which the result is returned, or the format of the output value enclosed in single quotation marks.

In Dialogue Manager, the format must be specified.


Top of page

Example: Converting a Mixed Case Field to Uppercase

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 don't want to see the field with all uppercase values, you can NOPRINT it.


Top of page

Example: Converting a Lowercase Field to Uppercase With MODIFY

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:

  1. The procedure prompts you for an employee ID, last name, first name, and department on a CRTFORM screen. The CRTFORM LOWER option retains the case of entries exactly as typed.

  2. You type the following data and press Enter:

    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
  3. The procedure searches the data source for the ID 444555666. If it does not find the ID, it continues processing the transaction.

  4. UPCASE converts the DEPARTMENT entry sales to 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
  5. The procedure adds the transaction to the data source.

  6. When you exit the procedure with PF3, the transaction message indicates the number of transactions accepted or rejected:

    TRANSACTIONS:         TOTAL =     1  ACCEPTED=     1  REJECTED=     0
    SEGMENTS:             INPUT =     1  UPDATED =     0  DELETED =     0