Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Look back in a sequential read

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Look back in a sequential read
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    Post subject:
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    Post subject:
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: 7996
Location: Bellevue, IA

PostPosted: Wed Sep 02, 2009 4:01 pm    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Wed Sep 02, 2009 9:48 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm
No new posts CICS VSAM RLS READ akodakka CICS 3 Tue Oct 04, 2016 3:09 pm
No new posts Multi row fetch - "for read only... Nileshkul DB2 3 Sun Aug 14, 2016 12:52 am
No new posts creating a physical sequential file i... Shaheen Shaik JCL & VSAM 8 Wed Jun 29, 2016 3:46 pm
No new posts To read from Zeke scheduler p.anbuselvan CLIST & REXX 5 Thu Mar 31, 2016 1:13 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us