LENGTH Function

The LENGTH function returns an integer equal to the length of the argument in character positions. This type of function is integer.

Usage

FUNCTION LENGTH (argument-1)

Parameters

  1. argument-1 may be a non-numeric literal or a data item of any class or category.
  2. If argument-1 (or any data item subordinate to argument-1) is described with the DEPENDING phrase of the OCCURS clause, the contents of the data item referenced by the data-name specified in the DEPENDING phrase are used at the time the LENGTH function is evaluated.

Returned Values

  1. If argument-1 is a non-numeric literal or an elementary data item, or if argument-1 is a group data item that does not contain a variable occurrence data item, the value returned is an integer equal to the length of argument-1 in character positions.
  2. If argument-1 is a group data item containing a variable occurrence data item, the returned value is an integer determined by evaluation of the data item specified in the DEPENDING phrase of the OCCURS clause for that variable occurrence data item. This evaluation is accomplished according to the rules in the OCCURS clause dealing with the data item as a sending data item.
  3. The returned value includes implicit FILLER characters, if any.
    Note: This function is similar in functionality to the Format 8 Set SET statement: SET result-item TO SIZE OF data-item.