View previous topic :: View next topic
|
Author |
Message |
suraaj
New User
Joined: 16 Apr 2009 Posts: 69 Location: Canada
|
|
|
|
Hi
I am having a table of 2000 items and I am loading the table depending on the value of a key say count. Once the table is loaded I am searching for an entry in the table against a value in a file. If they match I have to write it in a file. The file has ten records. The issue that I am facing is that the ten records from the file is only being matched with the first record. I am using SEARCH ALL...I see that this as a case of index non-initialization. I even tried with initialization still no success. Kindly help. |
|
Back to top |
|
|
don.leahy
Active Member
Joined: 06 Jul 2010 Posts: 765 Location: Whitby, ON, Canada
|
|
|
|
Is the table in the correct sort sequence? |
|
Back to top |
|
|
suraaj
New User
Joined: 16 Apr 2009 Posts: 69 Location: Canada
|
|
|
|
I have defined the table using the ascending key. So when the table is loaded it is in ascending sequence |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
suraaj wrote: |
I have defined the table using the ascending key. So when the table is loaded it is in ascending sequence |
No, did you load the table with the keys in the correct sequence, how the table is defined in COBOL does not mean the data is in the correct sequence, you have to ensure that when you load the data! |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Is the table fixed-length or variable-length (OCCURS DEPENDING ON)?
The table-data must be in sorted-order before you load it. COBOL will NOT ensure it's sorted as this is the programmer's responsibility.
Move HIGH-VALUES to the table before you load the sorted table-entries. Then if the number of entries is less than 2000, you'll have HIGH-VALUES at the end of the table, ensuring the SEARCH ALL will work.
What will you do if the number of table-entries exceeds 2000 at O'Dark thirty in the morning?
Where are you getting the table-data?
You might be better off defining the table to LINKAGE, where you can create a Dynamic-Table (via CEEGTST), based upon knowing the number of entries beforehand.
When defined in LINKAGE, you can define the table as a true ODO, 1 to 1677721 TIMES and allow an additional PIC 9(09) COMP variable, which represents the actual number of table entries.
For example -
Code: |
03 WS-STG-LGTH PIC 9(09) COMP.
LINKAGE SECTION.
01 LS-DYNAMIC-TBL.
03 LS-DYNAMIC-OCCURS PIC 9(09) COMP.
03 LS-DYNAMIC-ENTRIES OCCURS 1 TO 1677721 TIMES
DEPENDING ON LS-DYNAMIC-OCCURS
INDEXED BY X-LS-DT, X-LS-DT-MAX
PIC X(10).
|
|
|
Back to top |
|
|
suraaj
New User
Joined: 16 Apr 2009 Posts: 69 Location: Canada
|
|
|
|
The issue is reolved. I had not taken into consideration that the table has to be sorted explicitly. The table is created using depending on so that the table remains just enough long to contain the number of elements present.
Thanks for the solution Craq Giegerich |
|
Back to top |
|
|
|