ContentsIndexPreviousNext

5.9.3 OCCURS Clause

The Screen Section OCCURS clause simplifies the handling of repeated data items.

General Format

OCCURS table-size TIMES

Syntax Rules

1. Table-size is an integer that specifies the number of occurrences of the screen entry.

2. An OCCURS clause may not be specified for a screen entry that has a level-number of 01.

3. An OCCURS clause may be subordinate to a group item with an OCCURS clause to create a two-dimensional table. An OCCURS clause may not be nested more than two deep (three dimensional or greater tables are not allowed).

4. If an OCCURS clause applies to a screen output or update field, then one OCCURS clause specifying the same number of occurrences, or no OCCURS clause at all, must apply to the source item. This OCCURS clause must not include the DEPENDING phrase.

5. If an OCCURS clause applies to a screen input or update field, then one OCCURS clause specifying the same number of occurrences must apply to the receiving item. This OCCURS clause must not include the DEPENDING phrase.

6. If a COLOR clause is specified for a screen description entry that contains or is subordinate to an OCCURS clause, that COLOR clause may reference a table of numeric data items. The number of occurrences in the color table must match the number of occurrences in the screen entry.

General Rules

1. The general rules that apply to an OCCURS clause specified for a data item in the File, Working-Storage, or Linkage sections also apply to an OCCURS clause specified in the Screen Section. For specifics, see section 5.7.1.9, "OCCURS clause."

2. Each screen entry affected by an OCCURS clause is repeated table-size times.

3. If line or column numbers are given to screen items in a table, at least one of these numbers should specify relative positioning. If absolute positioning is used, then every occurrence of the screen item will appear in the same place.

4. If the screen item is an output or an update field, and no OCCURS clauses apply to the sending item, then a DISPLAY verb causes the sending item to be moved to every occurrence of the screen item.

5. If the screen item is an output or an update field with an OCCURS clause applying to the sending item, then a DISPLAY verb causes each occurrence of the sending item to be moved to the corresponding occurrence of the screen item.

6. If the screen item is an input or an update field, then an ACCEPT verb causes each occurrence of the screen item to be moved to the corresponding occurrence of the receiving item.

7. If a COLOR clause that references a table is specified, each occurrence of the table specifies the color for the corresponding occurrence of the screen item.

For Example:

DATA DIVISION.
WORKING-STORAGE SECTION.

01  DATA-TABLE.
    03  DATA-ELEMENT OCCURS 5 TIMES PIC X(5).

01  COLOR-TABLE.
    03  COLOR-ELEMENT OCCURS 5 TIMES PIC 9(5).

SCREEN SECTION.

01  SCREEN-1.
    03  OCCURS 5 TIMES, USING DATA-ELEMENT
        COLOR COLOR-ELEMENT.

More:

Example: Table on One Line

Example: Two-Element Table

Example with Output