INDEXED BY phrase
The INDEXED BY phrase specifies the indexes that can be used with a table. A table without an INDEXED BY phrase can be referred to through indexing by using an index-name associated with another table.
For more information about using indexing, see Subscripting using index-names (indexing).
Indexes normally are allocated in static memory associated with the program that contains the table. Thus indexes are in the last-used state when a program is reentered. However, in the following cases, indexes are allocated on a per-invocation basis. Thus you must set the value of the index on every entry for indexes on tables in the following sections:
- The LOCAL-STORAGE SECTION
- The WORKING-STORAGE SECTION of:
- A program with the IS INITIAL clause on the PROGRAM-ID phrase
- A class definition (object instance variables)
- The LINKAGE SECTION of:
- Methods
- Programs compiled with the RECURSIVE clause
- Programs compiled with the THREAD option
Indexes specified in an external data record do not possess the external attribute.
- index-name-1
- Each index-name specifies an index to be created by the compiler
for use by the program. These index-names are not data-names
and are not identified elsewhere in the COBOL program; instead, they
can be regarded as private special registers for the use of this object
program only. They are not data and are not part of any data hierarchy.
Unreferenced index names need not be uniquely defined.
In one table entry, up to 12 index-names can be specified.
If a data item that possesses the global attribute includes a table accessed with an index, that index also possesses the global attribute. Therefore, the scope of an index-name is the same as that of the data-name that names the table in which the index is defined.