Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

CHAR - Character in the alphanumeric collating sequence

The CHAR function returns a one-character alphanumeric value that is a character in the alphanumeric collating sequence having the ordinal position equal to the value of argument-1.
The type of this function is alphanumeric.

Format


FUNCTION CHAR (argument-1)


Arguments

  1. argument-1 must be an integer.

  2. The value of argument-1 must be greater than zero and less than or equal to the number of positions in the collating sequence.

Returned values

  1. If more than one character has the same position in the program collating sequence, the character returned as the function value is that of the first literal specified for that character position in the ALPHABET clause.

  2. The error default value is a space.


See also:
        ORD

Example 9-6

...
DATA DIVISION.
WORKING-STORAGE SECTION.
01  LETTER PIC 999 VALUE 194.
01  R PIC X.
PROCEDURE DIVISION.
P1 SECTION.
MAIN.
    MOVE FUNCTION CHAR (LETTER) TO R. 
    DISPLAY R UPON T.
    STOP RUN.

Result:   A
              The ordinal position of "A" in EBCDIC is 194.