Page 1 of 1

Error opening new empty VSAM File in I-O mode

PostPosted: Thu Jun 24, 2010 11:06 am
by kamal
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.

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

PostPosted: Thu Jun 24, 2010 12:37 pm
by expat
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.

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

PostPosted: Thu Jun 24, 2010 4:50 pm
by Robert Sample
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.