Error opening new empty VSAM File in I-O mode



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Error opening new empty VSAM File in I-O mode

Postby kamal » Thu Jun 24, 2010 11:06 am

In my COBOL program, I open a VSAM file in I-O mode to update records at some condition(s).
In my JCL am using DISP=MOD. When the Job runs for the first time, I am defining the VSAM file using IDCAMS.
But it fails to open the file in I/O mode.When I add records to newly defined file and then empty it , Job runs fine.

Hope I have expalined the problem.
kamal
 
Posts: 48
Joined: Wed Aug 22, 2007 2:49 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Error opening new empty VSAM File in I-O mode

Postby expat » Thu Jun 24, 2010 12:37 pm

Yes you have. The VSAM file needs to be initialised before being used. By loading and deleting records you are doing exactly that.

One of the few things that I was taught when I played COBOL was that any VSAM KSDS should have a high values and low values key record as standard to stop exactly that situation arising.

So when the KSDS was defined it was then loaded with two records and had no problems.
expat
 
Posts: 459
Joined: Sat Jun 09, 2007 3:21 pm
Has thanked: 0 time
Been thanked: 8 times

Re: Error opening new empty VSAM File in I-O mode

Postby Robert Sample » Thu Jun 24, 2010 4:50 pm

This is not a COBOL problem. VSAM files that are empty (that is, have never had a record in them) cannot be opened for input or I-O. This is a restriction on VSAM and you cannot get around it in any way I am aware of -- the VSAM file must be either opened for OUTPUT in your program, or at least one record written to it (the record can immediately be deleted) before it can be opened for input.
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post