Sunday, 28 July 2013

COND Parameter in JCL | COND Parameter Examples.

COND Parameter Example
COND Parameter in JCL

Today's tutorial is about the COND parameter in JCL. You’ll often find that job steps are dependent on one another. If one step ends abnormally, for example, you may not want to continue processing any subsequent steps. That’s why z/OS provides facilities that allow you to execute programs conditionally by using COND Parameters in JCL. In other words, you can specify whether to execute a job step based on the results of previous steps in the job.

What is the JOB Return Code?


When a program in a job step completes execution normally (that is, it doesn’t abend), it passes a value called a step return code back to Z/OS. This value indicates whether there were any problems with the execution and, if so, how severe they were. Then, at the end of a job, a system completion code indicates whether the job completed normally or not. 

What is the STEP Return Code?


Step return code A step return code (or just a return code or condition code) indicates whether or not a job step ran successfully. If a step ends normally, the return code is usually 0. But if the step does not end normally, the return code can have a value from 1 to 4095. The program that’s executed during the step determines what the return code will be and what it represents. 


Return Code Meaning
0
The program ran to successful completion.
4
The program encountered a minor error but was able to recover.
8
The program encountered a problem that inhibited successfully execution.
12
The program encountered a problem that inhibited successfully execution; normally, this indicates a more serious error than return code 8.
16
The program encountered a serious error and was not able to continue.

How to use the COND Parameter in JCL?


COND Parameter on a JOB statement to specify the conditions that cause a job to stop processing. If any of the steps within the job issues a return code that satisfies the condition, the system bypasses the remaining steps and terminates the job.

You can combine up to eight conditions on a single COND parameter. Then, if anyone of the conditions is true, the job terminates. This can be useful in situations where you are interested in stopping the job only if certain return codes are issued


The syntax for the COND parameter in a JOB statement 

COND=((value,operator)…)

Examples of the COND parameter on a JOB statement

The job will terminate if any job step has a return code of 8
//MM01C JOB (36512),'R RCTXT',COND=(8,EQ)

The job will terminate with a return code of 8 or a return code of 16 or greater
//MM01C JOB (36512),'R RCTXT',COND=((8,EQ),(16,LE))


The job will terminate with a return code of 8, 12, or 16

//MM01C JOB (36512),'R RCTXT',COND=((8,EQ),(12,EQ),(16,EQ))

Note:- This can be useful in situations where you are interested in stopping the job only if certain return codes are issued.

COND Parameter on an EXEC COND


COND = ( [ ( value, operator [ , stepname ] ) … ]
                [  , { EVEN }  { ONLY } ] )

EVEN
Tells the system to execute the job step even if a previous job step abended.
         ONLY
Tells the system to execute the job step only if a previous job step abended.


//STEP010   EXEC PGM=VIDUPD1,COND=(7,LT)
//STEPO30   EXEC PGM=VIDRPT3,COND=(8,EQ,SORT1) 

Note:- The job step is bypassed if SORT1 has a return code of 8

How to use the IF construct?

An IF construct can appear anywhere in the job after the first EXEC statement. The THEN clause and, if used, the ELSE clause must each contain at least one EXEC statement.

Example


//RTMX JOB (...) [JOB CARD]
//  IF RC= 8 THEN
//TRERR    EXEC PGM=ARD1345
//SYSOUT   DD SYSOUT=*
//ERRLOG   DD DSNAME=PRKT10.ERRLOG,DISP=MOD
//  ELSE
//TRSUM    EXEC PGM=PR5350
//SYSOUT   DD SYSOUT=*
//TRANFILE DD DSNAME=PRKT10.TRANFILE,DISP=SHR
//  ENDIF

No comments:

Post a comment