The ANY LENGTH Clause

The ANY LENGTH clause specifies that the length of a linkage section item may vary at runtime and is determined by the length of the argument.

General Format

  ANY LENGTH

Syntax Rules

  1. The ANY LENGTH clause must be specified only in an elementary level 1 entry in the Linkage Section of a function, of a contained program, or of a method that is not a property method.
  2. If the source element containing the ANY LENGTH clause is a contained program or is a method, the subject of the entry must be referenced in its PROCEDURE DIVISION header as either
    1. A formal parameter with the BY REFERENCE phrase, or
    2. The returning item.
  3. If the source element containing the ANY LENGTH clause is a function, the subject of the entry must be referenced in its PROCEDURE DIVISION header as a formal parameter with the BY REFERENCE phrase.
  4. A PICTURE clause must be specified for the subject of the entry, and the character-string specified in the PICTURE clause must be one instance of the picture symbols 'N' or 'X'.

General Rules

  1. The ANY LENGTH clause specifies that the subject of the entry must be:
    1. A zero-length item when the corresponding argument or returning item of the activating runtime element is a zero-length item, or
    2. Treated as though there were n repetitions of the picture symbol in the character-string in its PICTURE clause, where n is the length of the corresponding argument or returning item of the activating runtime element.
  2. ANY LENGTH can only be used where COBOL calls COBOL in an outer-most program, which can be a sub-program.