Pathway/iTS SCREEN COBOL Reference Manual (H06.10+, J06.03+)
SCREEN COBOL Source Program
HP NonStop Pathway/iTS SCREEN COBOL Reference Manual—426750-003
2-24
Tab les
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).










