Compaq COBOL AAQ2G1FTK User Manual

Page 126

Advertising
background image

Handling Tables
4.1 Defining Tables

The organization of this table is shown in Figure 4–3.

Figure 4–3 Organization of a Table with an Index and an Ascending Search

Key

C D C D C D C D C D

B

B

B

B

B

TABLE−A

0 0 0 0 0 0 0 0 0 1

1 2 3 4 5 6 7 8 9 0

Longword number

Byte number

Level 01

Level 05

Level 10

1

2

3

Legend: B = ELEMENTB

ZK−6041−GE

C = ITEMC
D = ITEMD

4.1.2 Defining Fixed-Length, Multidimensional Tables

Compaq COBOL allows 48 levels of OCCURS nesting. If you want to define a
two-dimensional table, you define another one-dimensional table within each
element of the one-dimensional table. To define a three-dimensional table, you
define another one-dimensional table within each element of the two-dimensional
table, and so on.

A two-dimensional table is shown in Example 4–4.

Example 4–4 Defining a Two-Dimensional Table

01

2D-TABLE-X.
05

LAYER-Y OCCURS 2 TIMES.
10

LAYER-Z OCCURS 2 TIMES.
15

CELLA PIC X.

15

CELLB PIC X.

The organization of this two-dimensional table is shown in Figure 4–4.

Example 4–5 shows a three-dimensional table.

The organization of this three-dimensional table is shown in Figure 4–5.

4–4 Handling Tables

Advertising