In a Cobol program, I am loading a sorted file that has around 100000 records first into an array defined for "search" and then an array defined for "search all". Then I am reading a file and searching a key record into both defined array separately. However, after searching the record into array defined for "search all" is giving around 1 % less records as compare to the array defined for "search". Other records are same. I think this should not happen and in both the cases I should get same file.

Do you initialize the "SEARCH ALL" file? If so, what do you initialize it to? How many table entries are there and how many are loaded from the file?

The COBOL SEARCH ALL verb mandates the table be sorted into ascending sequence. If your table is larger than the number of entries you loaded from the file, you must set the remaining entries to some value larger than the highest key value loaded (typically HIGH-VALUES is used) or the SEARCH ALL verb may not always return the correct results.

Actually, the table being referenced by a 'SEARCH ALL' can be in either ASCENDING KEY or DESCENDING KEY sequence. If ASCENDING KEY sequence, unused entries are typically filled with HIGH-VALUES, as Robert indicated. If DESCENDING KEY sequence, the unused entries are typically filled with LOW-VALUES.

Pankaj,
Are you saying that the total number of occurrences of the "search all" table is about 1% less than the total number of occurrences of the "search" table? Or are you saying that you get fewer "hits" during the SEARCH ALL than during the SEARCH? Please clarify. Also, please answer the questions by the dinosauer and Robert.

Do you initialize the "SEARCH ALL" file? If so, what do you initialize it to? How many table entries are there and how many are loaded from the file?

The COBOL SEARCH ALL verb mandates the table be sorted into ascending sequence. If your table is larger than the number of entries you loaded from the file, you must set the remaining entries to some value larger than the highest key value loaded (typically HIGH-VALUES is used) or the SEARCH ALL verb may not always return the correct results.

Yes, with SEARCH ALL verb, I am using sorted input file.
Can you please explain bit more this HIGH-VALUES thing.

Pankaj,
Are you saying that the total number of occurrences of the "search all" table is about 1% less than the total number of occurrences of the "search" table? Or are you saying that you get fewer "hits" during the SEARCH ALL than during the SEARCH? Please clarify. Also, please answer the questions by the dinosauer and Robert.

Hi Terry,
I was saying that I got fewer "hits" during the SEARCH ALL than during the SEARCH.

Where's your code that verifies the table is loaded in ascending sequence by WS-CES-SORT-KEY? Where do you verify that you do not have any duplicates in WS-CES-SORT-KEY in the table? From the COBOL Language Reference manual:

Quote:

The results of a SEARCH ALL operation are predictable only when:

* The data in the table is ordered in ASCENDING KEY or DESCENDING KEY order

* The contents of the ASCENDING or DESCENDING keys specified in the WHEN clause provide a unique table reference.

Where's your code that verifies the table is loaded in ascending sequence by WS-CES-SORT-KEY? Where do you verify that you do not have any duplicates in WS-CES-SORT-KEY in the table? From the COBOL Language Reference manual:

Quote:

The results of a SEARCH ALL operation are predictable only when:

* The data in the table is ordered in ASCENDING KEY or DESCENDING KEY order

* The contents of the ASCENDING or DESCENDING keys specified in the WHEN clause provide a unique table reference.