IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

File status 47


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
suraaj

New User


Joined: 16 Apr 2009
Posts: 69
Location: Canada

PostPosted: Thu Jul 11, 2013 11:54 pm
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Jul 12, 2013 12:09 am
Reply with quote

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
View user's profile Send private message
suraaj

New User


Joined: 16 Apr 2009
Posts: 69
Location: Canada

PostPosted: Fri Jul 12, 2013 12:20 am
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Jul 12, 2013 12:41 am
Reply with quote

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
View user's profile Send private message
Gary McDowell

Active User


Joined: 15 Oct 2012
Posts: 139
Location: USA

PostPosted: Fri Jul 12, 2013 12:44 am
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Jul 12, 2013 1:23 am
Reply with quote

Hello,

What causes your code to end when all of the input has been read?
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Jul 12, 2013 5:08 am
Reply with quote

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
View user's profile Send private message
suraaj

New User


Joined: 16 Apr 2009
Posts: 69
Location: Canada

PostPosted: Fri Jul 12, 2013 6:43 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Jul 12, 2013 6:47 pm
Reply with quote

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
View user's profile Send private message
suraaj

New User


Joined: 16 Apr 2009
Posts: 69
Location: Canada

PostPosted: Tue Jul 16, 2013 5:58 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Jul 16, 2013 8:01 pm
Reply with quote

Good to hear it is working - thank you for letting us know icon_smile.gif

d
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top