Your Browser is not longer supported

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

{{viewport.spaceProperty.prod}}

BYTE-LENGTH - Number of bytes

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

  1. argument-1 must be an alphanumeric or national literal or a data item of any class or category or type name.

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

  1. 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.
  2. 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.

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