Hi gus,
Yes, that will work for VSAM, but change the ORG to INDEXED.
Also, you have a choice of ACCESS MODEs - RANDOM, SEQUENTIAL, or DYNAMIC. I think SEQ is the default.
Now for the OPEN:
When a VSAM file defined as access RANDOM or DYNAMIC, is OPENed for INPUT or I-O and there were NEVER any records in it, a code of '90' is put into the FILE STATUS field and control is returned to your pgm and the stmt immediately following the OPEN stmt will be executed. This means that the OPEN was unsuccessful and any further attempts to access the file will fail.
If, on the other hand, it was defined as SEQUENTIAL or DYNAMIC and it was OPENed for OUTPUT, You would be preparing to load the file with data and the OPEN returns a code of '00'. Subsequent WRITEs to the file will be successful (God willing).
If, on the other other hand, the VSAM file contained records in the past that were deleted , leaving it with no records, you could define it with any ACCESS MODE and you could open it successfully for INPUT, I-O, EXTEND, even OUTPUT if you wanted to reload it. The return code is zero.
All of this still doesn’t answer your ques, but you should understand it if you want to understand the answer. The answer is ......
First you have to determine what kind of “empty” file you have, second, you have to decide what you want to do in each case.
You can define it ACCESS DYNAMIC, OPEN it for INPUT, If the file had records but is now “empty”, the FILE STATUS field s/b zero, then READ NEXT EOF etc. If EOF there are no records in the file, if not, you have records in the file and you can do direct READs (READs w/no NEXT) to process the file.
But suppose you get a ‘90’ on OPEN, what do you want to do?
There may be other approaches, stay tuned.
Regards, Jack.