2 initializing values of table elements – Compaq COBOL AAQ2G1FTK User Manual

Page 132

Advertising
background image

Handling Tables
4.2 Initializing Values of Table Elements

4.2 Initializing Values of Table Elements

You can initialize a table that contains only DISPLAY items to any desired value
in either of the following ways:

You can specify a VALUE clause in the record level preceding the record
description of the item containing the OCCURS clause.

You can specify a VALUE clause in a record subordinate to the OCCURS
clause.

Example 4–11 and Figure 4–10 provide an example and memory map of a table
initialized using the VALUE clause.

Example 4–11 Initializing Tables with the VALUE Clause

01 A-TABLE VALUE IS "JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC".

03 MONTH-GROUP PIC XXX USAGE DISPLAY

OCCURS 12 TIMES.

Figure 4–10 Memory Map for Example 4–11

Level 03

Longword number

Byte number

Level 01

ZK−6047−GE

1

2

3

A−TABLE

M

M

M

M

M

M

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

2 2 2 2 2 3 3 3 3 3 3 3

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

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

J A N F E B M A R A P R

S E P O C T N O V D E C

7

8

9

. . .

. . .

. . .

Legend: M = Month−Group

Byte contents

M

M

If each entry in the table has the same value, you can initialize the table as
shown in Example 4–12.

Example 4–12 Initializing a Table with the OCCURS Clause

01 A-TABLE.

03 TABLE-LEG OCCURS 5 TIMES.

05 FIRST-LEG

PIC X VALUE "A".

05 SECOND-LEG

PIC S9(9) COMP VALUE 5.

In this example, there are five occurrences of each table element. Each element
is initialized to the same value as follows:

FIRST-LEG occurs five times; each occurrence is initialized to A.

4–10 Handling Tables

Advertising