Table Handling Concepts
A table is a set of logically consecutive items, each of which has the same data description as the other items in the set. COBOL provides a method of data reference which makes it possible to refer to all or to part of one table as an entity.
In COBOL, a table is defined with an OCCURS clause in its data description. The OCCURS clause specifies that the named item is to be repeated as many times as stated. The item so named is considered a table element, and its name and description apply to each repetition (or occurrence) of the item. Because the occurrences are not given unique data-names, reference to a particular occurrence can be made only by specifying the data-name of the table element, together with the occurrence number of the desired item within the element.
The occurrence number is known as a subscript and the technique of supplying the occurrence number of individual table elements is called subscripting. Subscripting is described in a subsequent section.
- The subject of the OCCURS clause is used as the subject of the SEARCH statement.
- The subject (or subordinate data item) is the object of the ASCENDING/DESCENDING KEY clause.
- The subordinate data item is the object of the REDEFINES clause.
When the subject of an OCCURS clause is subscripted or indexed, it represents one occurrence within the table. Otherwise, the subject represents the entire table.
An item whose usage is POINTER or PROCEDURE-POINTER can contain an OCCURS clause, or be subordinate to an item declared with an OCCURS clause.
Tables containing pointer or procedure-pointer data items are subject to pointer alignment as defined under Pointer Alignment. Where necessary, the compiler adds FILLER items to align the pointers in the first element of the table, plus a FILLER item at the end of the element to align the next pointer. This continues until all pointers in the table have been aligned.
A boolean, external or internal floating-point, date, time, or timestamp item can contain an OCCURS clause, or be subordinate to an item declared with an OCCURS clause.
End of IBM Extension