IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Look back in a sequential read


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
shilpa.khaire

New User


Joined: 21 Jul 2006
Posts: 39
Location: US

PostPosted: Wed Sep 02, 2009 2:09 am
Reply with quote

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
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Wed Sep 02, 2009 6:24 am
Reply with quote

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
View user's profile Send private message
Bharath Bhat

Active User


Joined: 20 Mar 2008
Posts: 283
Location: chennai

PostPosted: Wed Sep 02, 2009 3:58 pm
Reply with quote

Close the file and open it again. Then start reading from the beginning.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Wed Sep 02, 2009 4:01 pm
Reply with quote

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
View user's profile Send private message
mjshaheed

New User


Joined: 09 Apr 2007
Posts: 25
Location: Chennai,India

PostPosted: Wed Sep 02, 2009 8:03 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Sep 02, 2009 9:48 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts Error to read log with rexx CLIST & REXX 11
No new posts Random read in ESDS file by using RBA JCL & VSAM 6
No new posts VSAM return code 23 - for a Random read COBOL Programming 4
No new posts ICETOOL to Read records SMF CEF it is... DFSORT/ICETOOL 4
Search our Forums:

Back to Top