Compaq COBOL AAQ2G1FTK User Manual
Page 125
Handling Tables
4.1 Defining Tables
Figure 4–2 Organization of Multiple Data Items in a One-Dimensional Table
1
1
2
3
4
A
B
B
Longword number
Byte number
Level 01
Level 05
Legend: A = TABLE−A
C
D
C
D
B = GROUP−B
C = ITEMC
D = ITEMD
ZK−6040−GE
Level 10
Example 4–1 and Example 4–2 both do not use the KEY IS or INDEXED BY
optional phrases. The INDEXED BY phrase implicitly defines an index name.
This phrase must be used if any Procedure Division statements contain indexed
references to the data name that contains the OCCURS clause. The KEY IS
phrase means that repeated data is arranged in ascending or descending order
according to the values in the data items that contain the OCCURS clause. (The
KEY IS phrase does not cause the data in the table to be placed in ascending or
descending order; rather, it allows you to state how you have arranged the data.)
For further information about these OCCURS clause options, see the Compaq
COBOL Reference Manual.
If you use either the SEARCH or the SEARCH ALL statement, you must specify
at least one index. The SEARCH ALL statement also requires that you specify
at least one key. Specify the search key using the ASCENDING/DESCENDING
KEY IS phrase. (See Section 4.3.8 for information about the SEARCH statement
and Section 4.3.4 for information about indexing.) When you use the INDEXED
BY phrase, the index is internally defined and cannot be defined elsewhere.
Example 4–3 defines a table with an ascending search key and an index.
Example 4–3 Defining a Table with an Index and an Ascending Search Key
01
TABLE-A.
05
ELEMENTB OCCURS 5 TIMES
ASCENDING KEY IS ITEMC
INDEXED BY INDX1.
10
ITEMC PIC X.
10
ITEMD PIC X.
Handling Tables 4–3