Reading a VSAM file with a condition.

Virtual Storage Access method - ESDS, KSDS, RRDS & LDS. Basic direct access method, Basic sequential -, Queued sequential -, Basic partitioned -, Indexed sequential -, Object - access method.
Post Reply
Abhishek Awasthi
Registered Member
Posts: 22
Joined: Tue Aug 20, 2013 10:43 am

Reading a VSAM file with a condition.

Post by Abhishek Awasthi »

Hi,

I have a VSAM with following key structure with key length of 110:

Code: Select all

01 VSAM-KEY-REC. 
05 VSAM-KEY-DATA PIC X(109). 
05 VSAM-KEY-FLAG PIC X(01). 
For my requirement, I need to read only those records which has VSAM-KEY-FLAG set to 'N'.

This is in my program:

Code: Select all

MOVE LOW-VALUES TO VSAM-KEY-DATA. 
MOVE 'N' TO VSAM-KEY-FLAG. 
*
READ VSAM-FILE 
KEY IS VSAM-KEY-REC 
END-READ. 
But it ends 23 VSAM status. I don't know the remaining keys of vsam i know only the last byte that is 'N'. Please help to resolve this one.

Thanks.
nicc
Global Moderator
Global Moderator
Posts: 691
Joined: Wed Apr 23, 2014 8:45 pm

Re: Reading a VSAM file with a condition.

Post by nicc »

You cannot! Generic keys must be at the start of the key. You probably can do what you want by using your sort product. Produce a sequential data set as the output and feed that into your program - assuming your program is going to do more than extract those records.
Regards
Nic
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1891
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Reading a VSAM file with a condition.

Post by Robert Sample »

Depending upon the exact task you're trying to do (and other factors, as always), you've got about 3 options:
1. As Nic suggested, use your sort product and put the records with 'N' into a sequential data set
2. Create an alternate index (with duplicates) on the last byte of the key, then use the alternate index in your program. This will work as long as you have no more than 32,767 records with an 'N' as the last byte of the key -- if there are more, this is NOT an option.
3. Sequentially read every record from first to last in your program, and work with the records that have the 'N'.
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “SMS & VSAM and BDAM, BSAM, QSAM, BPAM, ISAM, OAM.”