An elementary item described with USAGE IS INDEX is called an index data item. This is a data item (not necessarily associated with any table) which may be used to save values of index-names for future reference. An index data item is assigned the value of an index by the SET statement. The value of an index data item is not an occurrence number.
General rules
The USAGE clause with INDEX phrase may be written at any level. If a group item is described with USAGE IS INDEX, the elementary items in the group are all index data items; the group itself is not an index data item.
An index data item can be referenced directly only in a SEARCH statement, in a SET statement, in a relation condition, in the USING phrase of the Procedure Division header, or in the USING phrase of a CALL statement.
An index data item cannot be a conditional variable.
An index data item may be part of a group which is referenced in a MOVE statement or an input/output statement. When such statements are executed, however, the contents of the index data item are not converted.
SYNCHRONIZED, PICTURE or VALUE clauses cannot be used to describe group items or elementary items described with USAGE IS INDEX.
However, the compiler allows the SYNCHRONIZED clause to be used with the USAGE IS INDEX clause.
Example 7-32
02 ALPHA PICTURE X(9) OCCURS 5 INDEXED BY A-NAME. ... 77 A-INDEX USAGE IS INDEX. ... SET A-NAME TO 3. ... SET A-INDEX TO A-NAME.
Here the index data item A-INDEX is set to the current value of the index-name A-NAME, i.e. the occurrence number (3) minus 1, multiplied by the length of the entry (9) = 18.