Defining Tables

The ILE COBOL compiler allows tables in one to seven dimensions.

To define a one-dimensional table, set up a group item that includes one OCCURS clause. Remember that the OCCURS clause cannot appear in a data description entry whose level-number is 01, 66, 77, or 88.

For example:
01 TABLE-ONE.
05 ELEMENT-ONE OCCURS 3 TIMES.
   10 ELEMENT-A PIC X(4).
   10 ELEMENT-B PIC 9(4).

TABLE-ONE is the group item that contains the table. ELEMENT-ONE is an element of a one-dimensional table that occurs three times. ELEMENT-A and ELEMENT-B are elementary items subordinate to ELEMENT-ONE.

To define a three-dimensional table, a one-dimensional table is defined within each occurrence of another one-dimensional table, which is itself contained within each occurrence of another one-dimensional table. For example:
01 TABLE-THREE.
05 ELEMENT-ONE OCCURS 3 TIMES.
   10 ELEMENT-TWO OCCURS 3 TIMES.
      15 ELEMENT-THREE OCCURS 2 TIMES
         PICTURE X(8).

TABLE-THREE is the group item that contains the table. ELEMENT-ONE is an element of a one-dimensional table that occurs three times. ELEMENT-TWO is an element of a two-dimensional table that occurs three times within each occurrence of ELEMENT-ONE. ELEMENT-THREE is an element of a three-dimensional table that occurs two times within each occurrence of ELEMENT-TWO. Figure 1 shows the storage layout for TABLE-THREE.

Figure 1. Storage Layout for TABLE-THREE
This figure illustrates the storage layout for TABLE-THREE