beautypg.com

Compaq COBOL AAQ2G1FTK User Manual

Page 127

background image

Handling Tables

4.1 Defining Tables

Figure 4–4 Organization of a Two-Dimensional Table

1

2

ZK−6042−GE

2D−TABLE−X

LY

LY

LZ

LZ

LZ

LZ

A B A B A B A B

1 2 3 4 5 6 7 8

Longword number

Byte number

Level 01

Level 05

Level 10

Level 15

A = CELLA
B = CELLB

Legend: LY = LAYER−Y
LZ = LAYER−Z

Example 4–5 Defining a Three-Dimensional Table

01 TABLE-A.

05

LAYER-B OCCURS 2 TIMES.
10

ITEMC PIC X.

10

ITEMD PIC X OCCURS 3 TIMES.

10

ITEME OCCURS 2 TIMES.
15

CELLF PIC X.

15

CELLG PIC X OCCURS 3 TIMES.

Figure 4–5 Organization of a Three-Dimensional Table

Level 05

Longword number

Byte number

Level 01

ZK−6043−GE

1

2

3

A

B

0 0 0 0 0 0 0 0 0 1 1 1

1 2 3 4 5 6 7 8 9 0 1 2

Level 10

1 1 1 1 1 1 1 2 2 2 2 2

3 4 5 6 7 8 9 0 1 2 3 4

4

5

6

B

C D D D

E

E

G

F

G G F G G G

C D D D

E

E

G

F

G G F G G G

Level 15

Legend: A =

B =

ITEME

C =

TABLE−A

D =

CELLF

E =

CELLG

F =

LAYER−B

G =

ITEMC
ITEMD

4.1.3 Defining Variable-Length Tables

To define a variable-length table, use Format 2 of the OCCURS clause (refer to
the Compaq COBOL Reference Manual). Options allow you to define single or
multiple keys, or indexes, or both.

Example 4–6 illustrates how to define a variable-length table.

Handling Tables 4–5