View previous topic :: View next topic
|
Author |
Message |
GaganGarg
Active User
Joined: 31 Mar 2010 Posts: 134 Location: India
|
|
|
|
HI,
I am facing a S0C4 abend when I am trying to open a VSAM file in I-O mode. VSAM file is empty, access mode is dynamic, organization is indexed. Can anybody please tell me how to resolve this issue?
Thanks |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Why do you believe the open is causing an 0c4?
Suggest you load 1 record into the file and try again.
Also suggest you check the status after every command that uses the file. |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
Well thats a lot of info supplied for us to work with.
Lets starts guessing. Maybe the following will apply :
The file status codes must be checked after every VSAM I/O. For instance, if you do not check the VSAM status code after an OPEN statement and a bad open was encountered, you will get a "0C4" completion code when you try to reference the I/O area. This completion code indicates that addressability to the I/O area is not established until a valid open has been accomplished. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Quote: |
I am trying to open a VSAM file in I-O mode. VSAM file is empty |
This potentially is your first problem. When you say the VSAM file is empty, do you mean it is newly defined and has never contained records, or that it previously had records but they have all been deleted? The difference is important because a newly defined VSAM that has never had records in it CANNOT be opened for input, which means it cannot be opened for I-O either. This is a system restriction that you cannot get around. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hi Robert,
Robert wrote: |
This potentially is your first problem. |
From the movies. . .
Quote: |
Confidence is high, repeat, confidence is high. |
Wargames, American Pie. . .
It is still hard for me to grasp an entire generation of coders that have not had "Check the status EVERY time!" drilled into them by their instructors or project seniors. I guess it is roll-down from the point-n-click world where if it runs at all it is deployed and then dealt with when it goes thud. . .
d |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
I inherited a system last year. I was shocked to discover the previous programmer had actually removed all file status code variables and logic from the production programs (based on comments in the code). I'm still not sure why that was done, but other code in the system indicated this was not an ace programmer. One key program has the return code set to 20 if anything doesn't work, so when you get an RC 20, you get to go through all the code to figure out why the program didn't work. Why not use different codes for different conditions? I have no idea -- but it sure would have helped. |
|
Back to top |
|
|
GaganGarg
Active User
Joined: 31 Mar 2010 Posts: 134 Location: India
|
|
|
|
I displayed the Status code... it is 47. Actually the VSAM file is coming from another system, we can say VSAM file is provided by the client, so i can't say it was empty earlier or the records were deleted. simply i can say that VSAM file may be empty. I tried the code when VSAM file was having the records. Job ran fine. But now when VSAM file is empty, i am facing S0C4 and vsam status code is 47. Hope this info will help.
Thanks |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
The 47 is for the read, what was the status for the open? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
And if the OPEN was not successful, why was the program not terminated before ever trying to READ? |
|
Back to top |
|
|
GaganGarg
Active User
Joined: 31 Mar 2010 Posts: 134 Location: India
|
|
|
|
Yeah.. VSAM open status is 35(i.e. VSAM is empty). I want to execute the program even if VSAM is empty. Can anybody tell me please what to do in this case if VSAM is empty. I-O mode (access mode dynamic) is necessary here as i want to read the VSAM Sequentially from a particular record. I am using the START verb to put the pointer on a particular record and thereafter i want to read it sequentially, if the VSAM file is having the records
Please tell me some solution. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Load a record into the file. . .
You cannot open the file as input until a record has been added. . . The record can later be deleted. Did you read/understand what Robert posted previously?
Not a choice - a rule of vsam. |
|
Back to top |
|
|
GaganGarg
Active User
Joined: 31 Mar 2010 Posts: 134 Location: India
|
|
|
|
Hi all,
Thanks a lot. i got that we can't open VSAm file for I/P or I-O if it is already empty. I have put the logic in the program where i am checking the status of VSAm while opening it. If it is 35 then i am skipping the portion of the program which include the processing of the VSAM file. Thanks all. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
i got that we can't open VSAm file for I/P or I-O if it is already empty |
This is not correct. . . An empty file CAN be successfully opened. A file that has beed defined but never had a record written cannot be opened as input . . .
Quote: |
If it is 35 then i am skipping the portion of the program which include the processing of the VSAM file. |
There are other ways to get a status 35.
I believe the file should not be in this condition and that this should be corrected. . .
Even if this is "their" file and not "yours". |
|
Back to top |
|
|
Balraj
New User
Joined: 16 Aug 2007 Posts: 34 Location: Bangalore
|
|
|
|
An empty VSAM file can be opened in I-O with the OPTIONAL (SELECT OPTIONAL filename)and check the ok status with '00' and '05. I think this solve the problem of empty VSAM file handling. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Balraj, you are ALMOST right in what you said. From the COBOL Programming Guide (link at the top of the page):
Quote: |
Next Topic Match
1.10.3.2.1 Opening an empty file
To open a file that has never contained records (an empty file), use a form of the OPEN statement.
Depending on the type of file that you are opening, use one of the following statements:
* OPEN OUTPUT for ESDS files.
* OPEN OUTPUT or OPEN EXTEND for KSDS and RRDS files. (Either coding has the same effect.) If you coded the file for random or dynamic access and the file is optional, you can use OPEN I-O. |
Note that it must be ACCESS DYNAMIC or ACCESS RANDOM -- ACCESS SEQUENTIAL will not work for what you said. If you attempt to read from the file, you will get a file status 23. |
|
Back to top |
|
|
|