Your Browser is not longer supported

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

{{viewport.spaceProperty.prod}}

Indexing

Function

Indices are used when an individual element is to be accessed within a table (see the section "OCCURS clause").

Format 1

Describes indexing without qualification:


{data-name-1 | condition-name}  ({index-1 [{+ | -} integer ]} ... )


Format 2

Describes indexing with qualification:


{data-name-1 | condition-name} [{IN | OF} data-name-2] [{IN | OF} file-name]

({index-1 [{+ | -} integer]}... )


For a description of qualification with associated rules see section "Qualification".

Syntax rules for both formats

  1. data-name-1 is the name of a table element.

    If a data-name-1 is used with an index-name, then the data description entry of data-name-1 must either itself contain an OCCURS clause with an INDEXED BY phrase, or data-name-1 must be subordinate to a group item containing an OCCURS clause with an INDEXED BY phrase.

    For example, the reference

    TOTAL (INDEXA, INDEXB),

    implies that TOTAL belongs to a structure with two levels of OCCURS clauses, each with an INDEXED BY phrase specified.

  2. The index is enclosed in parentheses. The left parenthesis immediately follows the space after the name of the table element (data-name). When more than one index-name appears within a set of parentheses, these index-names may be separated either by commas followed by at least one space, or by spaces only.

  3. When the + integer or - integer phrase is used, the + and - characters must be preceded and followed by spaces.

  4. Index-names are written proceeding from the outermost to the innermost table.

  5. The lowest valid occurrence number for index-name is 1; the highest is, in any particular case, the maximum number of occurrences of the item. This maximum number is defined in the OCCURS clause. This same rule also applies to relative indexing.

  6. Referencing a table element, or an item within a table element, does not change the index-name associated with this table.

  7. The use of relative indexing will not change the values of indices in the object program.

General rules for both formats

  1. The values of indices may be stored without conversion (SET statement) in data items defined with the USAGE IS INDEX clause. These data items are then called index data items (see "USAGE clause" and "SET statement").

  2. An index may be modified only by a SET, SEARCH or PERFORM statement (see the descriptions of these statements).