View previous topic :: View next topic
|
Author |
Message |
shilpa.khaire
New User
Joined: 21 Jul 2006 Posts: 39 Location: US
|
|
|
|
Hi all,
I have 2 files which i need ot match. But under certain conditions, i need to scan the entire file (File 2) to get t he corresponding value for Amount field. Now for the next record, I might have to go back to the beginning of the file(file 2) to get this corresponding amount field.
First record:
Use the start Date (File 1) to look up a corresponding amount field in file 2.
Use the end date (File 1) to look up a corresponding amount field in file 2. This end date will be at the end of the file.
Second record:
Use the start Date (File 1) to look up a corresponding amount field in file 2. This can be anywhere between the start and end dates and since the file pointer is already at the end of the file due to the previous record, I cannot go back in the file.
This will happen even though the files are sorted. Is there a way to handle this look back in a sequential read? I was thinking of an internal table, but I will have to populate the table each time some other field(say field 1) changes. So this does not seem a good option considreing the number of reads that need ot be done. Other than a VSAM file, is there a simpler approach for this?
Thanks,
Shilpa |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
How many bytes of information do you need from each of your files and how many records are in each file. Internal tables might be the best way to go if the files/information don't exceed the maximum table sizes allowed. |
|
Back to top |
|
|
Bharath Bhat
Active User
Joined: 20 Mar 2008 Posts: 283 Location: chennai
|
|
|
|
Close the file and open it again. Then start reading from the beginning. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
VSAM file with direct read is probably your best bet. Closing and opening the file to read it over and over can be done but that may drive your run times through the roof, depending upon the number of records in the file.
COBOL variable storage can be up to 128 megabytes in the latest COBOL compiler -- if you're using it, an internal table might be the way to go as long as your data will fit into memory. |
|
Back to top |
|
|
mjshaheed
New User
Joined: 09 Apr 2007 Posts: 25 Location: Chennai,India
|
|
|
|
Robert is correct. During my early days in programming, i did the same mistake of opening and closing the file again and again and the job took more than 5hrs to run compared to 20mins before the change was made and i was tore apart by the client...
As far as my knowledge goes, the best way is to load the data into a table and do the search... |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
Close the file and open it again. Then start reading from the beginning. |
Only if you/your family has the hardware account. . .
This approach may be easier to code, but is most wasteful of system resources.
fwiw. . . |
|
Back to top |
|
|
|