Subscripting is a method of providing table references through the use of positive integers. A subscript is a positive integer (or integer data item) whose value specifies the occurrence number of a table element.
Subscripting - Format .-------------------------. V | >>-+-condition-name-1-+----+---------------------+-+------------> '-data-name-1------' '-+-IN-+--data-name-2-' '-OF-' >--+---------------------+--------------------------------------> '-+-IN-+--file-name-1-' '-OF-' .-----------------------------------------. V | >--(----+-integer-1---------------------------+-+--)----------->< +-ALL---------------------------------+ +-data-name-3--+-------------------+--+ | '-+-+--+--integer-2-' | | '- --' | '-index-name-1--+-------------------+-' '-+-+--+--integer-3-' '- --'
Data-name-3 can be qualified.
The subscripts, enclosed in parentheses, are written immediately following any qualification for the name of the table element. The number of subscripts in such a reference must equal the number of dimensions in the table whose element is being referenced. That is, there must be a subscript for each OCCURS clause in the hierarchy containing the data-name including the data-name itself.
When more than one subscript is required, they are written in the order of successively less inclusive dimensions of the data organization. If a multi-dimensional table is thought of as a series of nested tables and the most inclusive or outermost table in the nest is considered to be the major table with the innermost or least inclusive table being the minor table, the subscripts are written from left to right in the order major, intermediate, and minor.
01 TABLE-THREE.
05 ELEMENT-ONE OCCURS 3 TIMES.
10 ELEMENT-TWO OCCURS 3 TIMES.
15 ELEMENT-THREE OCCURS 2 TIMES PIC X(8).
a valid subscripted reference to TABLE-THREE is:
ELEMENT-THREE (2 2 1)
A reference to an item must not be subscripted unless the item is a table element or an item or condition-name associated with a table element.
The lowest permissible occurrence number represented by a subscript is 1. The highest permissible occurrence number in any particular case is the maximum number of occurrences of the item as specified in the OCCURS clause.