Community in read only mode June 18 & 19
This community will be set in READ ONLY mode for a while on Tuesday June 18 into Wednesday June 19 while we import content and users from our Micro Focus Forums community site. MORE INFORMATION

Multi-dimensional Tables: Subscript out of Range

Multi-dimensional Tables: Subscript out of Range


When attempting to access a multi-dimensional table outside of its subscript range, a “subscript out of range” error is not always generated at runtime.

Given an array M_TABLE:



       03   TABLE_DATA   PIC X(5).

And the Procedure Division statement:



If the values of x and y were 1 and 9 respectively, a ‘subscript out of range’ error is not generated at runtime even though the value in y is greater than the second dimension of the table.


The compiler directives that affect subscripting are SSRANGE and BOUND.


The comments in the BOUND section state:

For multi-dimensional tables, only the composite subscript is checked. If any of the individual subscripts or indices is beyond its limit, but the reference remains within the table, no error is produced.


In the example above, as the combined subscript (ie 1,9) is still within the physical bounds of the array, no error is produced at runtime, and the data will still be stored within the tables boundaries. This action means that any data already stored in the table could be overwritten and lost. Unpredictable results may be obtained when this area of the table is accessed further in the program.


As the Micro Focus compiler and run time processor can allow an individual subscript of a multi-dimensional table to be outside the range of its own occurrence, it is recommended that checking of subscripts is always coded to ensure this situation does not occur.

For example, in the above table:


IF (x < 1 OR > 😎

OR (y < 1 OR > 😎



               GO TO EXIT_PARA



Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2016-10-11 15:47
Updated by:
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.