MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Reading a VSAM file with partial key

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Data Management
View previous topic :: View next topic  
Author Message
sireesha_mca
Beginner


Joined: 11 Oct 2007
Posts: 2
Topics: 1

PostPosted: Wed Jan 09, 2008 4:13 am    Post subject: Reading a VSAM file with partial key Reply with quote

I need to search a KSDS VSAM file with generic or partial key, from a cobol batch program.
Can someone please provide me with the syntax?


Thanks in advance.
Back to top
View user's profile Send private message
jsharon1248
Intermediate


Joined: 08 Aug 2007
Posts: 291
Topics: 2
Location: Chicago

PostPosted: Wed Jan 09, 2008 9:02 am    Post subject: Reply with quote

Look at the START command in the COBOL Language Reference. That will set the initial file position for subsequent READs.
Back to top
View user's profile Send private message
sireesha_mca
Beginner


Joined: 11 Oct 2007
Posts: 2
Topics: 1

PostPosted: Thu Jan 10, 2008 1:50 am    Post subject: Reply with quote

SELECT file-1 ASSIGN TO abcd
ORGANIZATION IS INDEXED
ACCESS IS DYNAMIC
RECORD KEY IS ADOPT-KEY
ALTERNATE RECORD KEY IS ADOPT-KEY1
WITH DUPLICATES
STATUS IS ADOPT-STATUS.
The primary key composes of 3 fields and alrternate key is of 2 fields
READ file-1 key IS ADOPT-KEY1

even though my VSAM file has a record with the alternate key , it is giving a status code of '23'

we also used the start command (not working)

please suggest
Back to top
View user's profile Send private message
jsharon1248
Intermediate


Joined: 08 Aug 2007
Posts: 291
Topics: 2
Location: Chicago

PostPosted: Thu Jan 10, 2008 8:55 am    Post subject: Reply with quote

It appears that you're mixing the access methods. You're using the random read format on your READ which requires a key match. You should issue your START with the KEY IS and one of the relational clauses. The READ NEXT statements would follow the START.

Code:

START file-1 KEY >= ADOPT-KEY1
READ file-1 NEXT RECORD
PERFORM UNTIL ADOPT-STATUS = '23'
    <process record>   
    READ file-1 NEXT RECORD
END-PERFORM
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Data Management All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group