If the VSAM file is opened in I-O mode and it is newly created by the JCL we submit..then a read is being performed in cobol program to check whether it has existing records then the program fails as there are no records in the VSAM file..plz suggest how to handle this situation.
How the status codes should be managed to do a successful first time read of empty file...sample read statements are given below
ADD +1 TO XXX
MOVE 1 TO XXX
From the COBOL Programming Guide (link at the top of the page):
18.104.22.168.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.
Optional files are files that are not necessarily available each time a program is run. You can define files opened in INPUT, I-O, or OUTPUT mode as optional by defining them with the SELECT OPTIONAL clause in the FILE-CONTROL paragraph.
An empty VSAM file needs to be opened for OUTPUT (or EXTEND) before opening for INPUT or I-O. If you do SELECT OPTIONAL and open it for I-O, there can be performance implications.