Page 1 of 1

COBOL program and wrong DD name.

Posted: Mon May 09, 2016 8:22 am
by Om Prakash
Hi,
I have a simple program which simply opens a sequential output file, write in to and closes the file.  I faced a problem that the program compiled well and executed to. It allocates the file the output file do not have any records .

After a long a careful observation I came to know that the DD name in the JCL was spelled incorrectly. My question is, if the file name in COBOL didn't match the DD statement in the jobs JCL why did not I get an open error? Or some sort of other error to indicate this?

Re: COBOL program and wrong DD name.

Posted: Mon May 09, 2016 8:33 am
by Robert Sample
why did not I get an open error? Or some sort of other error to indicate this?
This is the whole reason file status codes are used.  You SHOULD be writing the FILE STATUS clause for every file in every COBOL program you code, and you SHOULD check them for every OPEN, READ, WRITE, CLOSE (etc) that you do.  And use the extended file status codes for VSAM so you get the additional information about VSAM errors.  If you had used FILE STATUS and checked it after the OPEN, you would have known the problem existed and the file status code usually gives you some direction on what the problem could be.

Re: COBOL program and wrong DD name.

Posted: Mon May 09, 2016 10:36 am
by William Collins
And to not get an abend, you have coded the FILE STATUS clause - and simply not checked it.

Which is the worst thing you can do. Because then any IO problems are ignored, because by using FILE STATUS you are telling the run-time that you want to check things, and then you don't bother.

Re: COBOL program and wrong DD name.

Posted: Tue May 10, 2016 3:25 pm
by Om Prakash
William Collins wrote:And to not get an abend, you have coded the FILE STATUS clause - and simply not checked it.

Which is the worst thing you can do. Because then any IO problems are ignored, because by using FILE STATUS you are telling the run-time that you want to check things, and then you don't bother.
Both of you are spot on, thanks! Yes, first I have not coded the FILE STATUS clause and then did not use it.