I have a requirement in which I have to load the data from a file into an array. The process is to read the second file and search for the data in the loaded array.
The data is sorted and I am using the first index for the Search all function. The code looks like below.
Code:
SEARCH ALL TABLE-ENTRIES
WHEN OFFICE(T-INDX) EQUAL TO WS-OFFICE AND
ACCTNO(T-INDX) EQUAL TO WS-ACCTNO AND
SECNO(T-INDX) EQUAL TO WS-SECNO
DISPLAY 'INSIDE THE SEARCH'
END-SEARCH.
Here if I use search instead of search all the code is working fine and I am getting the expected results. Can anyone please point out what needs to be done to resolve this issue?
Note that the data in both the files are sorted by the Keys in the table definition and I am not at all getting any displays in the sysout. I am reading the second file to a layout exactly similar to OFFICE thru INTL-RATE
The definition for the table looks like
Code:
07 TABLE-ENTRIES OCCURS 20000 TIMES
ASCENDING KEY IS OFFICE
ASCENDING KEY IS ACCTNO
ASCENDING KEY IS SECNO
INDEXED BY T-INDX.
10 OFFICE PIC S9(4) COMP-3.
10 ACCTNO PIC S9(8) COMP-3.
10 SECNO PIC X(9).
10 INTL-RATE PIC S9(7)V99 COMP-3.
part of the syntax for cobol internal table definitions.
You define a table with item(s) occcuring 1 to 100 times depending on var.
where var is a numeric item representing the number of items.
If a 'search all' is not bounded by an ODO clause, then the complete size of the table is taken into consideration. With the ODO clause, only active items are searched.
example:
odo 1 to 100 depending on var-1.
var-1 = 43. The search-all will only search 43 items. starting with item 26 or 27.
In the case of a 100 item fixed lengh table that only contains 43 items, a search-all will start with item 50, which contains ?. That is possibly why the OP is not getting a hit.
Thanks a lot Dick. That solved my issue entirely. I was struggling with this one for the last 24 hrs and I even coded a small pgm to test the functionality. I have made all the changes that you have told me and the pgm is just working fine….