Page 1 of 1

JCL (COND or IF)

PostPosted: Sat Aug 06, 2011 8:04 pm
by sanababu
in bypass activity which is most suitable wheather COND or IF Statement?????

Re: JCL

PostPosted: Sat Aug 06, 2011 8:16 pm
by enrico-sorichetti
when asking it would be wise to...
use a more intelligent title for Your questions
and post in the proper section of the forum

people willing to help do not like to waste time on questions with stupid/irrelevant titles
and posted in the wrong section

Re: JCL

PostPosted: Sun Aug 07, 2011 3:16 am
by dick scherrer
Hello,

As Enrico mentioned, it is best to use a meaningful subject and post in the proper part of the forum.

A subject of JCL is simply a waste. I've slightly modified your subject.

When asking a question you should post what you are working with and where you have a doubt. This is not a texting system and we expect even beginners to post complete thoughts. . .

Once you provide better info, someone will surely have a reply.

I can tell you up front, your answer is "It depends". . . .

Re: JCL (COND or IF)

PostPosted: Sun Aug 07, 2011 3:59 am
by steve-myers
As dick scherrer says, it depends.

Many people feel COND is very confusing. I'm among them, and I've been writing JCL for more than 40 years. On the other hand, the // IF statement is quite verbose, and it can be confusing for that reason.

For example -
//A       EXEC PGM=WEEKDAY
//          IF A.RC=0 THEN
//B       EXEC PGM=WTO,PARM='IT''S SUNDAY'
//        ELSE
//          IF A.RC=1 THEN
//C       EXEC PGM=WTO,PARM='IT''S MONDAY'
//        ELSE
//          IF A.RC=2 THEN
//D       EXEC PGM=WTO,PARM='IT''S TUESDAY'
//        ELSE
//          IF A.RC=3 THEN
//E       EXEC PGM=WTO,PARM='IT''S WEDNESDAY'
//        ELSE
//          IF A.RC=4 THEN
//F       EXEC PGM=WTO,PARM='IT''S THURSDAY'
//        ELSE
//          IF A.RC=5 THEN
//G       EXEC PGM=WTO,PARM='IT''S FRIDAY'
//        ELSE
//          IF A.RC=6 THEN
//H       EXEC PGM=WTO,PARM='IT''S SATURDAY'
//        ELSE
//I       EXEC PGM=WTO,PARM='I DON''T KNOW WHAT THE WEEK DAY IS!'
//       ENDIF
//       ENDIF
//       ENDIF
//       ENDIF
//       ENDIF
//       ENDIF
//       ENDIF
The WEEKDAY program returns the day of the week when it's run as a return code from 0 to 6, and WTO does what it appears to do.

Compare the previous JCL with -
//A       EXEC PGM=WEEKDAY
//B       EXEC PGM=WTO,COND=(0,NE,A),PARM='IT''S SUNDAY'
//C       EXEC PGM=WTO,COND=(1,NE,A),PARM='IT''S MONDAY'
//D       EXEC PGM=WTO,COND=(2,NE,A),PARM='IT''S TUESDAY'
//E       EXEC PGM=WTO,COND=(3,NE,A),PARM='IT''S WEDNESDAY'
//F       EXEC PGM=WTO,COND=(4,NE,A),PARM='IT''S THURSDAY'
//G       EXEC PGM=WTO,COND=(5,NE,A),PARM='IT''S FRIDAY'
//H       EXEC PGM=WTO,COND=(6,NE,A),PARM='IT''S SATURDAY'

Re: JCL (COND or IF)

PostPosted: Sun Aug 07, 2011 4:49 am
by MrSpock
I'm an IF/THEN/ELSE guy myself, always have been. Just my preference.

Re: JCL (COND or IF)

PostPosted: Mon Aug 08, 2011 7:20 pm
by Ed Goodman
My guess would be that younger folks would like the if/then/else better. I'm right on the cusp and have used both enough to see they have advantages.

For new JCL, I would code it using if/then/else, but make it so that the jobs are short (few steps) and are always restarted from the top should something go wrong.

Older jobs with twenty steps and two main IMS programs that may need a restart on steps 5 12 and 17 should keep the COND statements.