UPCASV: Creating a Variable Length Uppercase String

How to:

Available Languages: reporting

UPCASV converts alphabetic characters to uppercase, and is similar to UPCASE. However, UPCASV can return AnV output whose actual length is the lesser of the actual length of the AnV source string and an input parameter that specifies the upper limit.

Syntax: How to Create a Variable Length Uppercase String

UPCASV(upper_limit, source_string, output)

where:

upper_limit

Integer

Is the limit for the length of the source string. It can be a positive constant or a field whose integer portion represents the upper limit.

source_string

Alphanumeric of type An or AnV

is the string to convert to uppercase. It can be the character string enclosed in single quotation marks ('), or the field containing the character string. If it is a field, it can have An or AnV format. If it is a field of type AnV, its length is taken from the length in bytes stored in the field. If upper_limit is smaller than the actual length, the source string is truncated to the upper limit.

output

Alphanumeric of type An or AnV

Is the field to which the result is returned, or the format of the output value enclosed in single quotation marks ('). This can be a field with AnV or An format.

If the output format is AnV, the length returned is equal to the smaller of the source string length and upper_limit.

Example: Creating a Variable Length Uppercase String

Suppose you are sorting on a field that contains both uppercase and mixed-case values. The following request defines a field called LAST_NAME_MIXED that contains both uppercase and mixed-case values:

DEFINE FILE EMPLOYEE
LAST_NAME_MIXED/A15=IF DEPARTMENT EQ 'MIS' THEN LAST_NAME ELSE
LCWORD(15, LAST_NAME, 'A15');
LAST_NAME_UPCASV/A15V=UPCASV(5, LAST_NAME_MIXED, 'A15') ;
END

Suppose you execute a request that sorts by this field:

TABLE FILE EMPLOYEE
PRINT LAST_NAME_MIXED AND FIRST_NAME BY LAST_NAME_UPCASV
WHERE CURR_JOBCODE EQ 'B02' OR 'A17' OR 'B04';
END

The output is:

LAST_NAME_UPCASV  LAST_NAME_MIXED  FIRST_NAME
----------------  ---------------  ----------
BANNI             Banning          JOHN
BLACK             BLACKWOOD        ROSEMARIE
CROSS             CROSS            BARBARA
MCCOY             MCCOY            JOHN
MCKNI             Mcknight         ROGER
ROMAN             Romans           ANTHONY