An table (or "array") is a series of repeating data elements. The individual elements of an table are referenced within programs by appending a subscript to the element name.
The following Cobol code specifies a table having 10 elements of 5 bytes each. The total size of the table is 50 bytes.
01 MY-TABLE. 02 MY-ELEMENT OCCURS 10 TIMES PIC X(5).
In the above example MY-ELEMENT (7) would be the notation to reference the seventh element of the table. (7) is the subscript.
In the next example an table of 200 elements is specified. Each element of the table consists of 6 bytes each.
01 TRANSCRIPT-TABLE.
02 COURSE-ITEM OCCURS 200 TIMES.
03 COURSE-ID PIC X(5).
03 FINAL-GRADE PIC X(1).
In the above example COURSE-ITEM (1) would be the notation to indicate the first course stored in the table. If we only wanted to reference the final grade of that first course, we would use the notation COURSE-ID (1).
An table may have more than one dimension. In the following example we have created a two dimensional table of course registrations. We assume this table is part of each student's transcript record.
01 TRANSCRIPT-TABLE.
02 ACADEMIC-SEMESTER OCCURS 20 TIMES.
03 COURSE-ITEM OCCURS 10 TIMES.
04 COURSE-ID PIC X(5).
04 FINAL-GRADE PIC X(1).
In the above example we allow for a maximum of twenty semesters per student. Within each semester we allow for the student to be registered for a maximum of ten courses.
The student's final grade for the third course in the fourth semester would be written as: FINAL-GRADE (4,3)