I am trying to do a SEARCH ALL in a COBOL program, but I am getting a not found condition even when the data is present. The data populated into USER-TABLE varies for each run. The table can have anywhere from 5 to 500 records. I am now testing with 6 records. When the table size is specified as 500, I am getting â€˜not foundâ€™ for all the 6 rows. When the table size is reduced to 10, data is found for all rows except the last row. I replaced the â€˜SEARCH ALLâ€™ with a search (array size 500) for the same data and got the correct result. I displayed the values in the table as they are populated and it is in the sorted order on the key. Can you please have a look at the below code and help me to correct the issue?
05 WS-USER-TABLE OCCURS 500 TIMES
WS-USER-V, WS-USER-VA, WS-USER-VO
INDEXED BY USR-INDX.
10 WS-USER-V PIC X(09).
10 WS-USER-VA PIC X(09).
10 WS-USER-VO PIC X(06).
10 WS-USER-DATA1 PIC X(07) VALUE SPACES.
10 WS-USER-DATA2 PIC X(01) VALUE SPACE.
10 WS-USER-DATA3 PIC X(30) VALUE SPACES.
10 WS-USER-DATA4 PIC X(01) VALUE 'N'.
Initializing the table. Done before table is populated with values
VARYING USR-INDX FROM 1 BY 1
UNTIL USR-INDX > WS-MAX-USR-INDX
MOVE HIGH-VALUES TO WS-USER-V (USR-INDX)
Search in the program
MOVE SPACE TO WS-SAVE-IN
PERFORM 1000-WRITE-OUT THRU 1000-EXIT
PERFORM 2000-READ-IN THRU 2000-EXIT
WHEN WS-USER-V (USR-INDX) = WS-EXT-V AND
WS-USER-VA(USR-INDX) = WS-EXT-VA AND
WS-USER-VO(USR-INDX) = WS-EXT-VO
PERFORM 2100-PROCESS THRU 2100-EXIT