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

Sequential and dynamic read for same VSAM file in a program


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

Active User


Joined: 03 Nov 2005
Posts: 275
Location: Mumbai

PostPosted: Thu Nov 19, 2009 12:24 pm
Reply with quote

Hi All,

I want to read a KSDS VSAM file sequentially as well as as Randomly in same program. My requirement is as below

01 VSAM-REC
05 VSAM-KEY.
10 A PIC S9(08) COMP
05 B PIC S9(8) COMP.

Logic Need to be accomplished:

1. Open the VSAM file and start reading sequentially from first record
2. At a particular record I want to use value in Field 'B' as VSAM Key and
read the same vsam file dynamically use this dynamically read record
business purpose
3. Continue the sequential read

here my doubt is can we read the same file dynamically without affecting the sequential read.

Please help me out in this I will be very thankful

Regards,
Chandan
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Thu Nov 19, 2009 12:58 pm
Reply with quote

You could try the following :

save the key
init the key with the new value
do a direct read
do a start with the old key

Don't know if that will work, cause the ACB and RPL control blocks
have to be set up for sequential and direct reading
Back to top
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Thu Nov 19, 2009 2:33 pm
Reply with quote

Hi Chandan,

An alternate to the solution proposed by Peter...

Assuming that you only need to do read operations and no write operations are involved... icon_smile.gif
Before starting the COBOL program, in your JCL you could copy the VSAM to a temporary PS file and use this particular file to do the sequential read... Maintain the VSAM for the RANDOM read...
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: Thu Nov 19, 2009 6:05 pm
Reply with quote

Why not use one file definition for the direct access and one for the sequential access? Since you're not updating, there's no chance for deadly embraces, and COBOL as well as z/OS support doing this. Just use different DD names for the direct and sequential files and point them to the same VSAM file.
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Thu Nov 19, 2009 7:03 pm
Reply with quote

Sure Robert, thats the easy way to do it. But then you have at least 2 ACB's, RPL's and buffer pools.

Using one file definition gives you the chance that the record to be read
directly is already in the buffer pool, reducing IO.
But maybe that is too far fetched. And to be fair i dont know what kind of
controlblocks Cobol will generate for doing sequential/skip sequential/direct processing on one file definition.
I did this kind of VSAM processing in assembler a lot of times and it worked like a charm.
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 Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Using API Gateway from CICS program CICS 0
Search our Forums:

Back to Top