Pathway/iTS SCREEN COBOL Reference Manual (G06.24+, H06.03+, Pathway/iTS 1.0+)

SCREEN COBOL Source Program
Compaq NonStop™ Pathway/iTS SCREEN COBOL Reference Manual426750-001
2-24
Tables
Tables
Tables of data are common in data processing problems. For example, a data structure
might have 20 total fields, described as twenty identical data items named total-one,
total-two, ..., total-twenty. This would mean twenty different names, which could
obscure the interrelated nature of the totals and make references awkward. A table
structure simplifies this situation.
Tables are defined with an OCCURS clause in their data description. This clause
specifies that an item is repeated as many times as stated. The item is considered to be a
table element, and its name and description apply to each repetition. For example, the
one-dimensional table mentioned in the preceding paragraph could be defined with this
entry:
02 total OCCURS 20 TIMES ...
In the Screen Section, a table must be an elementary item. In the Working-Storage
Section and Linkage Section, the elements of a table can be groups of subordinate
structures, some of which can also be tables. Thus, the previous example might appear
in greater detail as:
02 total-g OCCURS 20 TIMES.
03 total-a ...
03 total-b OCCURS 3 TIMES ...
The expanded example describes total-a as a one-dimensional table, and describes total-
b as a two-dimensional table because an OCCURS clause is applied to an item
subordinate to the first OCCURS clause. If the description of a data item subordinate to
total-b also had an OCCURS clause, the item would be a three-dimensional table.
SCREEN COBOL allows a maximum of three dimensions in the Working-Storage
Section and Linkage Section.
Frequently, tables are built in the Working-Storage Section with constant values that a
program needs in addition to the data from external sources. An example of coding for a
table containing the full calendar month names is:
WORKING-STORAGE SECTION.
01 month-name-table.
05 FILLER PIC X(9) VALUE "JANUARY".
05 FILLER PIC X(9) VALUE "FEBRUARY".
05 FILLER PIC X(9) VALUE "MARCH".
05 FILLER PIC X(9) VALUE "APRIL".
05 FILLER PIC X(9) VALUE "MAY".
05 FILLER PIC X(9) VALUE "JUNE".
05 FILLER PIC X(9) VALUE "JULY".
05 FILLER PIC X(9) VALUE "AUGUST".
05 FILLER PIC X(9) VALUE "SEPTEMBER".
05 FILLER PIC X(9) VALUE "OCTOBER".
05 FILLER PIC X(9) VALUE "NOVEMBER".
05 FILLER PIC X(9) VALUE "DECEMBER".
01 month-name-rtable REDEFINES month-name-table.
05 month-name OCCURS 12 TIMES PIC X(9).
The term FILLER is a keyword that takes the place of a data name when it is
unimportant to name an item. Because occurrences of a table element do not have