Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Sequential and dynamic read for same VSAM file in a program

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
chandan.inst

Active User


Joined: 03 Nov 2005
Posts: 269
Location: Mumbai

PostPosted: Thu Nov 19, 2009 12:24 pm    Post subject: Sequential and dynamic read for same VSAM file in a program
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: 2445
Location: Netherlands, Amstelveen

PostPosted: Thu Nov 19, 2009 12:58 pm    Post subject:
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    Post subject:
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: 8195
Location: East Dubuque, Illinois, USA

PostPosted: Thu Nov 19, 2009 6:05 pm    Post subject:
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: 2445
Location: Netherlands, Amstelveen

PostPosted: Thu Nov 19, 2009 7:03 pm    Post subject:
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    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 The same REXX program doesnt work for... jackzhang75 CLIST & REXX 5 Wed Dec 06, 2017 2:51 am
No new posts File Tailoring -- Temporary dataset i... samzee71 CLIST & REXX 3 Fri Dec 01, 2017 3:12 am
No new posts Rexx - File tailoring samzee71 CLIST & REXX 10 Thu Nov 30, 2017 10:47 pm
No new posts Compare VSAM files using DFSORT pshongal DFSORT/ICETOOL 5 Thu Nov 23, 2017 10:24 am
No new posts Moving a PS file as body of a mail! Vignesh Sid JCL & VSAM 4 Tue Nov 21, 2017 9:23 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us