beautypg.com

Handling tables 4.1 defining tables – Compaq COBOL AAQ2G1FTK User Manual

Page 131

background image

Handling Tables

4.1 Defining Tables

Figure 4–8 Memory Map for Example 4–9

Level 03

Longword number

Byte number

Level 01

1

2

3

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

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

7

8

ZK−6045−GE

4

5

6

A−TABLE

1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 3

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

GROUP−G

GROUP−G

GROUP−G

GROUP−G

1 3 3 3 2 2 2 2 1 3 3 3 2 2 2 2 1 3 3 3 2 2 2 2 1 3 3 3 2 2 2 2

Level 05

Legend: 1 = ITEM1

2 = ITEM2
3 = ITEM3

If, however, you place ITEM3 after ITEM2, the additional 3 bytes add their own
length plus another fill byte. The additional fill byte is added after the third
ITEM3 character to ensure that all occurrences of the table element are mapped
in an identical manner. Now, each element requires 12 bytes, and the complete
table occupies 48 bytes. This is illustrated by Example 4–10 and Figure 4–9.

Example 4–10 How Adding 3 Bytes Adds 4 Bytes to the Element Length

01 A-TABLE.

03 GROUP-G OCCURS 4 TIMES.

05 ITEM1 PIC X.
05 ITEM2 PIC 9(5) COMP SYNC.
05 ITEM3 PIC XXX.

Note that GROUP-G begins on a 4-byte boundary because of the way Compaq
COBOL allocates memory.

Figure 4–9 Memory Map for Example 4–10

1

2

3

4

5

6

Level 03

Longword number

Byte number

Level 01

0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2

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

. . .

. . .

. . .

. . .

. . .

A−TABLE

f

f

f

2 2 2 2 3 3 3 f

1

1 f

f

f

2 2 2 2 3 3 3 f

Legend: 1 = ITEM1
2 = ITEM2
3 = ITEM3
f = fill byte

GROUP−G

GROUP−G

Level 05

ZK−6046−GE

Handling Tables 4–9