View previous topic :: View next topic
|
Author |
Message |
suraaj
New User
Joined: 16 Apr 2009 Posts: 69 Location: Canada
|
|
|
|
I am having a VSAM file opened in I-O mode. I am reading the file randomly using a key. But when I do the reading I am getting the file status as 47. I want to read the file and see if the record exists based on the key. If it does that update the file (REWRITE) and otherwise write the record into the file. Kindly help. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Did you even check the manual to see what file status 47 means? If so, you would have found
Quote: |
The execution of a READ statement was attempted on a file not open in the
input or I-O mode. |
and you would know that one of these issues occurred:
(1) your file did not open and you did not check the file status code on OPEN,
(2) the file was processed then closed, and your code "fell through" into the READ again,
(3) you did not open the file in INPUT or I-O mode,
etc .... |
|
Back to top |
|
|
suraaj
New User
Joined: 16 Apr 2009 Posts: 69 Location: Canada
|
|
|
|
Hi Robert,
I had in initiated this thread only after going through the manuals and I had made sure that they are not happening. I am opening the file at the beginning in the I-O mode and then reading the file till the end of the file. When I am reading the records and checking for existence is when I am getting this. I am doing the debug in xpediter thats the reason I am so sure.
Please advise.
Regards Suraaj |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
The system is telling you that the file is not open in INPUT or I-O mode when your code executes the READ statement. This is what a 47 file status code means.
Whether or not you believe it does not really matter. Nor does it matter that you are using Xpediter to debug the code. The only thing that matters is that the system is telling you when the READ is being executed the file is not open in INPUT nor I-O mode -- period. You may continue to state contrary opinions as long as you want, but the fact remains -- as long as you do not accept that the file is not open for INPUT / I-O mode when that particular READ statement is executed, you will not be able to resolve the problem you posted.
If you want further assistance, you'll need to post the SELECT, the OPEN, the READ statement in question, using the CODE button. |
|
Back to top |
|
|
Gary McDowell
Active User
Joined: 15 Oct 2012 Posts: 139 Location: USA
|
|
|
|
Maybe the file was OPENed and then CLOSEd ? Your file is definitely not OPENed when your do your READ.
Status Key 47
The execution of a READ statement was
attempted on a file not open in the
INPUT or I-O mode.
Code: |
Select your-file Assign to your-dd
Organization INDEXED
Access RANDOM
Record key MAIN-KEY {in record description}
File Status WS-STATUS. {in Working-Storage} |
|
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
What causes your code to end when all of the input has been read? |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
COBOL also has the "extended FILE-STATUS" for VSAM files which gives information about what VSAM tells you happened. Include that as well. |
|
Back to top |
|
|
suraaj
New User
Joined: 16 Apr 2009 Posts: 69 Location: Canada
|
|
|
|
Thanks all...
I am getting a file status 39 for the open file. So much for the file status 47 for the read statement. Still pondering for the 39 status.
Regards Suraaj |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
There should be nothing mysterious about a 39 . . .
Between the code and the file, there is most likely a length mis-match. |
|
Back to top |
|
|
suraaj
New User
Joined: 16 Apr 2009 Posts: 69 Location: Canada
|
|
|
|
The issue was with the offset. I had started the offset from 1 instead of 0 so instead of 1768 I had given 1769 in the offset of key. Thanks Dick Scherrer, Bill Woodger, Gary McDowell and Robert Sample. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Good to hear it is working - thank you for letting us know
d |
|
Back to top |
|
|
|