View previous topic :: View next topic
|
Author |
Message |
Anil George
New User
Joined: 13 Feb 2008 Posts: 7 Location: India
|
|
|
|
Hi all,
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. |
|
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
have you loaded 20000 items into the table?
if not, you need to use an ODO clause.
and why have you coded it this way:
Code: |
ASCENDING KEY IS OFFICE
ASCENDING KEY IS ACCTNO
ASCENDING KEY IS SECNO
|
and not this way?
Code: |
ASCENDING KEY IS OFFICE ACCTNO SECNO
|
|
|
Back to top |
|
|
sri_mf
Active User
Joined: 31 Aug 2006 Posts: 218 Location: India
|
|
|
|
dbzTHEdinosauer wrote: |
have you loaded 20000 items into the table?
if not, you need to use an ODO clause.
[/code] |
can u explain this ODO clause..n wats its use |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
ODO - occurs depending on
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. |
|
Back to top |
|
|
sri_mf
Active User
Joined: 31 Aug 2006 Posts: 218 Location: India
|
|
|
|
dbzTHEdinosauer wrote: |
ODO - occurs depending on
. |
Thanks for ur reply dick..I know Occurs depending On..
Onseeing ODO i thought that its something else...n it confused me..
Gud word ODO.. |
|
Back to top |
|
|
Anil George
New User
Joined: 13 Feb 2008 Posts: 7 Location: India
|
|
|
|
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….
Thanks once again Dick…. You just made my day!!!
Anil |
|
Back to top |
|
|
|