View previous topic :: View next topic |
Author |
Message |
sireesha_mca Beginner
Joined: 11 Oct 2007 Posts: 2 Topics: 1
|
Posted: Wed Jan 09, 2008 4:13 am Post subject: Reading a VSAM file with partial key |
|
|
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 |
|
 |
jsharon1248 Intermediate
Joined: 08 Aug 2007 Posts: 291 Topics: 2 Location: Chicago
|
Posted: Wed Jan 09, 2008 9:02 am Post subject: |
|
|
Look at the START command in the COBOL Language Reference. That will set the initial file position for subsequent READs. |
|
Back to top |
|
 |
sireesha_mca Beginner
Joined: 11 Oct 2007 Posts: 2 Topics: 1
|
Posted: Thu Jan 10, 2008 1:50 am Post subject: |
|
|
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 |
|
 |
jsharon1248 Intermediate
Joined: 08 Aug 2007 Posts: 291 Topics: 2 Location: Chicago
|
Posted: Thu Jan 10, 2008 8:55 am Post subject: |
|
|
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 |
|
 |
|
|