beautypg.com

Compaq COBOL AAQ2G1FTK User Manual

Page 133

background image

Handling Tables

4.2 Initializing Values of Table Elements

SECOND-LEG occurs five times; each occurrence is initialized to 5.

Often a table is too long to initialize using a single literal, or it contains numeric,
alphanumeric, COMP, COMP-1, COMP-2, or COMP SYNC items that cannot be
initialized. In these situations, you can initialize individual items by redefining
the group level that precedes the level containing the OCCURS clause. Consider
the sample table descriptions illustrated in Example 4–13 and Example 4–14.
Each fill byte between ITEM1 and ITEM2 in Example 4–13 is initialized to X.
Figure 4–11 shows how this is mapped into memory.

Example 4–13 Initializing Mixed Usage Items

01 A-RECORD-ALT.

05 FILLER PIC XX VALUE "AX".
05 FILLER PIC S99 COMP VALUE 1.
05 FILLER PIC XX VALUE "BX".
05 FILLER PIC S99 COMP VALUE 2.
.
.
.

01 A-RECORD REDEFINES A-RECORD-ALT.

03 A-GROUP OCCURS 26 TIMES.

05 ITEM1 PIC X.
05 ITEM2 PIC S99 COMP SYNC.

Figure 4–11 Memory Map for Example 4–13

1

1

2

3

4

Longword number

Byte number

Level 01

Level 05

5

6

7

8

2

A−RECORD

A−GROUP

A−GROUP

1

f

2

2

1

f

2

2

A

X

B

X

ZK−6048−GE

Level 03

Byte contents

binary 2

binary 1

Legend: 1 = ITEM1

2 = ITEM2

f = fill byte

. . .

. . .

. . .

. . .

. . .

As shown in Example 4–14 and in Figure 4–12, each FILLER item initializes
three 10-byte table elements.

Handling Tables 4–11