View previous topic :: View next topic
|
Author |
Message |
feellikeneo
New User
Joined: 19 Mar 2007 Posts: 73 Location: Chennai
|
|
|
|
I'm trying to read a VSAM file in my COBOL code using START command.
I am getting status code=23 when I try to read one record. I can confirm that the record I try to read is present in the VSAM file.
The below is my VSAM read,
Code: |
START <VSAM_FILE_NAME>
KEY IS GREATER THAN <KEY_REC>
|
The interesting part here is - to overcome this issue, we insert a dummy record with key value as 99999999999999 (key length is 14) at the end of the VSAM file and we process the VSAM successfully.
Could you please throw us some light why we are getting this error and how this workaround works. Is the issue related to by record or anything to do with setup. |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
You can't read a file with the START command, you should use READ instead...
But you can use START to position yourself before reading.
If the key is present, use KEY GREATER OR EQUAL otherwise you will just miss the record you want. |
|
Back to top |
|
|
feellikeneo
New User
Joined: 19 Mar 2007 Posts: 73 Location: Chennai
|
|
|
|
Hi Marso,
Exactly said.. I am issuing a START command prior to my read command.
I used START command with KEY GREATER THAN... And i am getting return code 23.
Appreciate your assistance. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
From the manual, a 23 file status means
Quote: |
An attempt was made to randomly access
a record that does not exist in the
file, or a START or random READ
statement was attempted on an optional
input file that was not present. |
If the key you're doing the START on has a larger value than any key in the VSAM file, you will get a 23 file status code. Adding a higher-valued key (such as HIGH-VALUES or all 9's) puts a record in the file with a key value higher than what you do the START on, and VSAM will return this record. |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
If the file is not optional and is present, then it is:
Quote: |
An attempt was made to randomly access a record that does not exist in the file |
Do you check the status also after the OPEN statement ?
Have you DISPLAYed the key before the START command, just to make sure you have a correct value ?
Try to do a START with KEY GREATER THAN LOW-VALUES and check if you can read the file at all. |
|
Back to top |
|
|
feellikeneo
New User
Joined: 19 Mar 2007 Posts: 73 Location: Chennai
|
|
|
|
Apologizes for the delayed response...
Robert,
Rightly said.. I checked my file again. Though the key which I was looking for was there in the VSAM file, I could not find any key which is greater than that..
Thank you very much for your info... |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Neo: You could use GE (GREATER THAN OR EQUAL TO) rather than GT is your KEY clause; this would allow the READ to return a record with exact key match. As you've got the code, it'll only return a record with a higher key value. |
|
Back to top |
|
|
|