COBOL program and wrong DD name.

OS/VS COBOL, COBOL II, Enterprise COBOL for z/OS. OpenCOBOL and OOCobol.
Post Reply
Om Prakash
Registered Member
Posts: 22
Joined: Tue Jul 23, 2013 3:22 pm

COBOL program and wrong DD name.

Post 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?
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1886
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: COBOL program and wrong DD name.

Post 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.
William Collins
Global Moderator
Global Moderator
Posts: 490
Joined: Sun Aug 25, 2013 7:24 pm

Re: COBOL program and wrong DD name.

Post 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.
Om Prakash
Registered Member
Posts: 22
Joined: Tue Jul 23, 2013 3:22 pm

Re: COBOL program and wrong DD name.

Post 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.
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “IBM COBOL, GnuCOBOL (OpenCOBOL), OOCobol.”