Some legacy programs use a technique that involves defining tables with minimum values for ‘OCCURS’ and addressing items beyond the defined value; the special options required to make this technique function properly under Server Express and Net Express are explained in this article.
Problem:
Legacy programs sometimes use the following technique to handle large numbers of items in a table. Consider the following example code:
WORKING-STORAGE SECTION.
01 CNT PIC 9(5) VALUE 1.
01 BIG-AREA PIC X(1000).
01 BLLS-TABL PIC S9(8) COMP-5 VALUE 0.
01 PLLS-TABL REDEFINES BLLS-TABL USAGE IS POINTER.
LINKAGE SECTION.
01 TABLE-RECORD.
02 T-ID OCCURS 3 TIMES INDEXED BY T-INDEX.
03 TD-ENTRY-NUMBER PIC 9(5).
03 TD-FIELD PIC X(10).
PROCEDURE DIVISION USING TABLE-RECORD.
0000-START..
** Set the address of Big-area to the TABLE-RECORD
SET PLLS-TABL TO ADDRESS OF BIG-AREA.
SET ADDRESS TABLE-RECORD TO ADDRESS OF BIG-AREA.
SET T-INDEX TO 1.
0001-LOOP.
MOVE CNT TO TD-ENTRY-NUMBER(T-INDEX).
MOVE "AAAAAAAAAA" TO TD-FIELD(T-INDEX).
SET T-INDEX UP BY 1.
ADD 1 TO CNT.
IF CNT > 50
GO TO 0002-LOOP
ELSE
GO TO 0001-LOOP.
0002-LOOP.
DISPLAY 'T-ID=' T-ID (T-INDEX) ' CNT='CNT.
SET T-INDEX UP BY 1.
DISPLAY "END OF JOB"
STOP RUN.
The Table now contains far more occurrences than allowed for during compilation. Processing all of the items in the now too large table is obviously problematic, and special care is required.
Resolution:
To properly handle the "too large" table, two compiler directives are required: The application must be compiled with the NOBOUND and the NOBOUNDOPT directives.
NOBOUND disables the checking for invalid subscripts and indexes at run time, NOBOUNDOPT disables the optimization of the increment of the INDEX variable. This is required because the program will have to increment far beyond the limits of the table definition.