View previous topic :: View next topic
|
Author |
Message |
seahawk789
New User
Joined: 22 Feb 2010 Posts: 56 Location: Cochin
|
|
|
|
I have a VSAM file with key as 2 fields of 5 bytes each
Code: |
KEYFIELD1 - 5 BYTES
KEYFIELD2 - 5 BYTES
...
Other data fields
|
However in my program I know the value for only 1 key - KEYFIELD1. Also I know that even if I retrieve data using KEYFIELD1 still it will return only 1 record. As a result in my program I have declared only KEYFIELD1 as the attribute
Code: |
01 KEY-VSAM
05 KEYFIELD1 PIC X(05)
|
and using that I am executing CICS read statement
Code: |
EXEC CICS READ
DATASET (TVSAM-FILE)
RIDFIELD (KEY-VSAM)
KEY LENGTH (LENGTH OF KEYVSAM)
INTO (WS-REC)
RESP (WS-RESPONSE)
EQUAL
END-EXEC
|
Now since the key attribute of the actual VSAM file differs from what I have in my code will the above statement be successful ? or if not is it possible to handle the error condition in WS-RESPONSE ?
Or the only option is to use STARTBR AND THEN READNEXT ?
Please help. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
If your VSAM key is 10 bytes, it is 10 bytes. It is not made of two parts, or one part or 10 - or, to put it another way. VSAM doesn't know or care.
Reading a VSAM file with a key only returns a record for an exact match.
If you only know a partial, leading, part of the key, then the rest of the key you set to a value lower than can be reasonably expected (binary zeros is the most effective) and use whatever is provided to "start" from that particular point in the file, and then use one or more sequential "reads". |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
As you have only a partial key, you have to use the GENERIC option in your EXEC CICS READ statement. |
|
Back to top |
|
|
seahawk789
New User
Joined: 22 Feb 2010 Posts: 56 Location: Cochin
|
|
|
|
Thanks. So the below code should work.
Code: |
EXEC CICS READ
DATASET (TVSAM-FILE)
RIDFIELD (KEY-VSAM)
KEY LENGTH (LENGTH OF KEYVSAM)
INTO (WS-REC)
RESP (WS-RESPONSE)
GENERIC
END-EXEC
|
|
|
Back to top |
|
|
Pete Wilson
Active Member
Joined: 31 Dec 2009 Posts: 580 Location: London
|
|
|
|
Are the 2 keys of the records contiguous? If not you'd have to be looking at using an alternate index to access the file based on the second key value. |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3049 Location: NYC,USA
|
|
|
|
As suggested by Pete , I would also suggest to use alternate index. However, when you use GENERIC you should be able to get the data. |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
Quote: |
I have a VSAM file with key as 2 fields of 5 bytes each
|
That is NOT possible (like Mr. Woodger stated), and if you want to do a generic read, supply the total length (10 bytes) and the keyfield as a 10 byte field. |
|
Back to top |
|
|
|