• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 794
  • Last Modified:

query regarding cond codes

what is the meaning of Cond Codes in JCL

JCL COND Codes are used to execute steps based on the condition that previous executed statement does not have

specified return code.

For example COND=(0,NE)- It means that if the return code (RC) of every previous step is equal to zero then
execute this step.


Am I right or I have missed something. If no then please explain it with an example.

Regards
Karan Gupta
0
KaranGupta
Asked:
KaranGupta
2 Solutions
 
Gary PattersonVP Technology / Senior Consultant Commented:
It has been many, many years since I had to write any JCL, but I'll try to help:

See the "Conditional Processing" section of the this page for a good explanation and examples, including comparative pseudocode:

http://en.wikipedia.org/wiki/Job_Control_Language

This tutorial also presents a mechanism for converting English language conditional logic into JCL COND parameters.  It is a little confusing at first, but it does present a good number of examples:

http://teaching.idallen.org/dat2330/01s/jclnotes/conditionCodes.txt

- Gary Patterson
0
 
AmbusyCommented:
COND=(0,NE) does NOT execute the step, if the condition  is true.
COND=(4,GT) would execute if all rc's were less or equal to 4. (NOT is any > 4)
And likewise.
As there is no stepname (as 3rd parameter)( the test is made against every prededing step.
If a stepname is specified the returncode of that step only is tested.
0
 
AmbusyCommented:
If you are writing (or changing) JCL, change to IF THEN ELSE ENDIF.
A bit easiere to understand, though always IBM-JCL, not the best there is, but then it's over 40 years since HASP was invented, and Jes3 is still compatible with the Houston Automatic Spool.
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
giltjrCommented:
I agree with Ambusy, if you are creating new jobs or updating old ones, go with the new IF THEN statements.  Much easier to understand.

Even with 25+ years of coding JCL, the old COND= still confuses me and takes me awhile to figure out in some cases.

The IF/THEN/ELSE/ENDIF makes it a lot easier.
0
 
KaranGuptaAuthor Commented:
Hi

Please check it now

=========================================================
JCL Cond Codes are used to decide whether to execute the current step or not, based on the return code(RC) of the previously executed step.
 
For example: 1. //STEP02 EXEC PGM=PROG03,COND=(8,LE)
- It means that “STEP02” will not be executed if the return code of every executed previous step is greater than equal to 8.
 
2. //STEP02 EXEC PGM=PROG02,COND=(4,GT,STEP01)
- It means that “STEP02” will not be executed if the return code of “STEP01” is less than equal to 4.
 
So we can conclude that the COND parameter on the EXEC statement will skip this step if the condition is TRUE for *any* of the previous steps.
====================================================================
0
 
TommySzalapskiCommented:
Very close. Just remember the differences with GT and GE
LE (<=) is the compliment of GT (>), LT (<) is the compliment of GE (>=)

I annotated some modifications.

=========================================================
JCL Cond Codes are used to decide whether to execute the current step or not, based on the return code(RC) of the previously executed steps.       <---added the s
 
For example: 1. //STEP02 EXEC PGM=PROG03,COND=(8,LE)
- It means that “STEP02” will not be executed if the return code of every executed previous step is greater than 8.
 
2. //STEP02 EXEC PGM=PROG02,COND=(4,GT,STEP01)
- It means that “STEP02” will not be executed if the return code of “STEP01” is less than equal to 4.
 
So we can conclude that the COND parameter on the EXEC statement will skip this step if the condition is TRUE for the specified step or *any* of the previous steps if no step is specified.
====================================================================
0
 
aikimarkCommented:
It is such reverse-logic handling of step conditional execution that many shops recoded their JCL into REXX or TSO scripts.
0
 
giltjrCommented:
Using IF THEN ELSE in JCL makes it much easier.  Your example:

     //STEP02 EXEC PGM=PROG03,COND=(8,LE)

Is changed to:

     //IF01  IF RC <= 8 THEN
     //STEP02 EXEC PGM=PROG03
     //ENDIF01

or even:

     //IF01  IF RC > 9 THEN
     //STEP02 EXEC PGM=PROG03
     //ENDIF01

And:

     //STEP02 EXEC PGM=PROG02,COND=(4,GT,STEP01)

Is changed to:

     //IF01  IF STEP01.RC > 4 THEN
     //STEP02 EXEC PGM=PROG02
     //ENDIF01

Also with the IF-THEN-ELSE you can have real else's like:

     //IF01  IF STEP01.RC > 4 THEN
     //STEP02A EXEC PGM=PROG02
     // ELSE
     //STEP02B EXEC PGM=PROG09
     //ENDIF01

You can also using things like IF ABEND or IF RUN.  IF ABEND will run a step if a prior step abended.  IF RUN will run a step if a prior step ran.  You can use NOT's, AND's and OR's.  The JCL IF-THEN-ELSE is just like any other IF-THEN-ELSE.

Although you can convert to REXX, TSO CLIST, or some other "scripting" language, using JCL IF-THEN-ELSE does require any major changes to your job steams.
0
 
monro1964Commented:
{Edited by _alias99}

The way you use the COND code command on this question (See on TOP), the Steps with COND command are EXECUTE only if the result of the COND condition is FALSE.

I know, it confusing.


You can also look at a new way to code the COND command. It is if IF and ENDIF. It is more easy to understand.


//S1     exec myproc1
//cond01 if rc = 0 then
//c01ok  exec myproc2
//c01e   else
//c01els exec myproc3
//       endif


or

//S1     exec myproc2
//*
//s2     exec myproc1
//*
//cond03 if s2.rc = 0 then
//c03ok  exec myproc2
//c03e   else
//c03els exec myproc3
//       endif
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now