The CHAR function returns an integer value that is the length in bytes of argument-1.
The type of this function is integer.
Format
FUNCTION
BYTE-LENGTH
(argument-1)
Arguments
argument-1 must be an alphanumeric or national literal or a data item of any class or category or type name.
If any data item subordinate to argument-1 is described with the DEPENDING phrase of the OCCURS clause, the content of the DEPENDING data item at the time the LENGTH function was analyzed is used.
Returned values
If argument-1 is a non-numeric literal, an elementary item or a group item which contains no variable-length data item, the return value is the length of argument-1 in bytes.
If argument-1 is an object reference then the length of the object reference and not the size of the object itself is returned.If argument-1 is a group item to which a variable-length data item is subordinated, the return value is the length of argument-1 in bytes. It is calculated in accordance with the rules for a sending item with OCCURS clause.
The return value takes into account implicit FILLER characters which occur in argument-1.
See also: LENGTH
Example 9-5
... DATA DIVISION. WORKING-STORAGE SECTION. 01 RES PIC 9(3). PROCEDURE DIVISION. MAIN. COMPUTE RES = FUNCTION LENGTH (N"Rats live on no evil star"). DISPLAY RES UPON T. STOP RUN.
Result: 050