Handling VSAM status code 35 in JCL

2.1k Views Asked by At

My COBOL program reads a VSAM file that may or may not be empty. When the file is empty i get a status code 35 while opening in INPUT/I-O mode. I do not want to handle it in program but in a JCL. Is there any way by which VSAM file can be checked if it is empty or not...if it is not possible through a JCL then can we handle it in program without having to check status code 35?

3

There are 3 best solutions below

0
On

I seem to recall that you could use IDCAMS to repo the file into a dummy dataset and you would get an RC=4 if it was empty.

That is from memory a few years ago, but then you could put that check in your job stream before running your program and control execution of the next step using the IDCAMS return code.

0
On

Add OPTIONAL to the SELECT clause in the FILE-CONTROL paragraph.

SELECT OPTIONAL fdname
    ASSIGN TO ddname
    ...
0
On

When you get a starus "35" exit the program with a

MOVE 8 TO RETURN-CODE.
GOBACK.

[example here][1]

http://ibmmainframes.com/about60344.html

You can then test for a non-zero return code in your JCL with a COND=8 on the next step which will only execute when your program detected an empty file.