INDEX is set to a high number.
Posted: Wed May 29, 2019 7:02 pm
There is a table in COBOL program which is defined like this:
Now later in the program it is used like this:
My question is on the last line of 3000-paragraph. Why would someone set an INDEX to 6000 while the table OCCURS only 5000 times? Is not it a wrong code?
This is an existing code and I am just analyzing it for some other issue so code is not written by me but is it a common practice to set the Index like this?
Code: Select all
05 TAB-REC OCCURS 5000 TIMES.
10 TABLE-NEW PIC X(08).
10 TABLE-OLD PIC X(08).
10 TABLE-TYP PIC X(03).
Code: Select all
3000-GET-MATCHING-JOB.
IF AU-NEW-JOB-NAME = TABLE-NEW(INDX)
MOVE TABLE-TYP(INDX) TO SAVE-AU-JOB-TYP
MOVE TABLE-OLD(INDX) TO SAVE-AU-OLD-JOB-NAME
MOVE 'Y' TO GOT-JOB-SW
MOVE 11000 TO INDX
ELSE
IF TABLE-NEW(INDX) = SPACES
MOVE 6000 TO INDX.
This is an existing code and I am just analyzing it for some other issue so code is not written by me but is it a common practice to set the Index like this?