Saturday, 10 August 2013

COND Parameter in JCL | JCL COND Examples | COND Conditional Job Processing | [JCL COND Parameter]


cond parameters in JCL

JCL COND Parameter

Welcome back to today's session on "COND Parameter in JCL". In this session, you'll learn the basics of the JCL cond parameter, how to use multiple cond parameters in JCL, and cond parameters override in JCL.

You'll reinforce your JCL COND parameter knowledge with basic JCL COND examples (i.e. JCL cond code to bypass step, JCL cond=(0 le), JCL condition codes interview questions, JCL cond=(0, NE), JCL cond=(4, lt)). Let's get started with an introduction to JCL.

JCL COND Parameter - Agenda.

  • Introduction to JCL.
  • What is COND Parameter in JCL?
  • What are Return Code (RC) and System code in JCL?
  • How COND Parameters in JCL work?
  • JCL COND parameters syntax.
    • JCL COND EVEN or JCL COND ONLY.
  • JCL COND Parameter Example - Summary.
  • COND Parameter in JCL Examples. 
  • Conclusion.

Introduction to JCL.

The term JCL stands for "JOB Control Language". It's the command language of the z/OS operating system. Ideally speaking JCL is a scripting language and it a combination of multiple job control statements (i.e. JOB Card, Execute Statement, and DD statements).

JCL has multiple steps and each check is a combination of the EXEC statement and DD statements. But, sometimes you the requirement to skip or execute certain job steps based on certain condition. The conditional execution of JOB steps is termed as conditional processing of JCL (i.e. JCL conditional processing).

What are COND Parameters in JCL?

In laymen's terms, the "JCL COND parameter" is one of the most important and vital parameters that is used for JCL conditional processing. However, you can also use the "IF/THEN-ELSE/ENDIF" statement to process job steps conditionally.

Now, before discussing the JCL COND syntax. Let's try to understand the difference between "Return code" and "System Completion Code".

What is Return Code (RC) in JCL?

An application program can return code at the end of the step termed as "Return Code or Completion Code". You can use these return codes in JCL cond parameters to either skip the processing or execute the steps.

What is System Completion Code in JCL?

The other category of code is "System Completion Code". In this category the operating system return code at the end of the job completion.

How COND Parameters in JCL works?

JCL COND parameter allows the execution of job steps depend on the return code (i.e. RC) from previous steps. For example, if a compilation fails, there is no need to attempt a subsequent linkage editor or execution step in the job. If the COND parameter in JCL is omitted then the system will execute all steps with a testing return code of the previous steps.

You can use the JCL COND parameter to specify the return code tests the system uses to decide whether a job will continue processing or terminates. Before and after each job step is executed, the system performs the JCL COND parameter tests against the return codes (i.e. RC) from completed job steps.

If none of these tests is satisfied, the system executes the job step (i.e. JCL conditional step execution); if any test is satisfied, the system bypasses all remaining job steps (i.e. "JCL COND code to bypass step") and terminates the job.

The tests are made against return codes (i.e. RC) from the current execution of the job. A job step is bypassed because an EXEC statement COND parameter does not produce a return code.

Bypassing a step because of a return code test is not the same as abnormally terminating the step. The system abnormally terminates a step following an error so serious that it prevents successful execution. In contrast, bypassing a step is merely its omission.

JCL COND Parameter Syntax.

The following is the syntax of COND parameters in JCL. 

COND=((code,operator)[,(code,operator)]...)

  • Code - The CODE parameter is used to specifies a number that the system matches to the return code (i.e. RC) from each job step. The return code value must be between 0 through 4095.
  • Operator - The operator parameter is used to specifies the type of comparison to be made to the return code (i.e. RC). If the specified return code is tested true, the system bypasses all remaining job steps (i.e. cond parameter to bypass a step in JCL). Following are the operator which is used to specify COND parameters in JCL. 


Operator          |            Meaning 
  GT                               Greater than
  GE                               Greater than or Equal to
  EQ                               Equal to
  LT                                 Less than
  LE                                 Less than or Equal to
  NE                                Not Equal to

If you code the COND parameter on the JOB statement and on one or more of the job's EXEC statements, and if a return code test on the JOB statement is satisfied, the job terminates. In this case, the system ignores any EXEC statement COND parameters.

If the tests on the JOB statement are not satisfied, the system then performs the return code tests on the EXEC statement. If an EXEC return code test is satisfied, the step is bypassed.

JCL COND EVEN or JCL COND ONLY. 

JCL COND parameter is more flexible on the EXEC statement than the COND parameter on the JOB statement. It lets you specify a return code (i.e. JCL COND=(0, NE)) and a relational operator (i.e. )to determine whether to skip a particular job step (i.e. JCL cond code to bypass step) instead of all subsequent steps.

Also, you can define a step name to test the return code (i.e. RC) for a specific job step. JCL COND parameter also provides two additional subparameters, EVEN and ONLY, that let you specify how an abend affects job step execution.

JCL COND parameter syntax on EXEC statement.

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

  • EVEN - Directs the system to execute the job step even if a prior job step is abended.
  • ONLY - Indicates the system to execute the job step only if a former job step is abended.

Important Point - You can code the JCL COND EVEN or JCL COND ONLY sub-parameters to specify which steps to be executed when the previous job step failed. 

JCL COND Parameter Example - Summary.  

In the following JCL COND example, you'll have a summary of the condition code and how the job step will behave to each condition code. 

JCL COND parameter | Return Code (RC) from the 
                         previous job step.

Continue job |  Terminate job
COND=(code,GT)    | RC >= code |  RC <  code
COND=(code,GE)    | RC > code |  RC <= code
COND=(code,EQ)    | RC ¬= code |  RC =  code
COND=(code,LT)    | RC <= code |  RC >  code
COND=(code,LE)    | RC < code |  RC >= code
COND=(code,NE)    | RC = code |  RC ¬= code

Now, let's deep dive into the cond parameters in JCL examples.

#1. COND parameter in JCL to skip a step or COND parameter to bypass a step in JCL.

In the following example, the STEP02 will be bypass if the STEP01 return code is 8 or greater than 8.
 
//TPTRICK01 JOB 'TOPICTRICK',MSGCLASS=A,CLASS=C,
//               MSGLEVEL=(1,1),NOTIFY=&SYSUID
//STEP01 EXEC PGM=SORT
//....
//....
//STEP02 EXEC PGM=EMPTAX01,COND=(7,LT) 
//....
//....
//

#2. Multiple conditions in COND Parameter in JCL.

In the following example, the STEP03 will be bypass if the STEP01 return code equal to 8 or STEP02 has a return code of 12 or greater. 

//TPTRICK01 JOB 'TOPICTRICK',MSGCLASS=A,CLASS=C,
//               MSGLEVEL=(1,1),NOTIFY=&SYSUID
//STEP01 EXEC PGM=SORT
//....
//STEP02 EXEC PGM=EMPTAX01
//....
//STEP03 EXEC PGM=EMPTAX02,COND=((8,EQ,STEP01),(12,LE,STEP02)) 
//....
//....
//

#3. JCL COND=EVEN Example.

In the following example, the STEP02 will be executed if the STEP01 has failed due to any reason. 

//TPTRICK01 JOB 'TOPICTRICK',MSGCLASS=A,CLASS=C,
//               MSGLEVEL=(1,1),NOTIFY=&SYSUID
//STEP01 EXEC PGM=SORT
//....
//....
//STEP02 EXEC PGM=EMPTAX01,COND=(EVEN) 
//....
//....
//


#4. JCL COND=ONLY Example.

In the following example, the STEP02 will be executed only if the STEP01 has failed due to any reason. 

//TPTRICK01 JOB 'TOPICTRICK',MSGCLASS=A,CLASS=C,
//               MSGLEVEL=(1,1),NOTIFY=&SYSUID
//STEP01 EXEC PGM=SORT
//....
//....
//STEP02 EXEC PGM=EMPTAX01,COND=(ONLY) 
//....
//....
//


#5. JCL COND parameter overrides in JCL Example.

If you want to implement the test to the return code (i.e. RC) from a specific step within a procedure, then you have to follow the sequence of sub-parameters (number, comparison, stepname.procstep).

In the following example, the system bypass STEP02, if 4 is less than the return code (i.e. RC) from the GO step of the TAXPROC procedure executed by step020.

//TPTRICK01 JOB 'TOPICTRICK',MSGCLASS=A,CLASS=C,
//               MSGLEVEL=(1,1),NOTIFY=&SYSUID
//STEP01 EXEC TAXPROC
//....
//....
//STEP02 EXEC PGM=REPTAX,COND=(4,LT,STEP01.GO) 
//....
//....
//

#6. JCL COND Override proc Example.

Let say, you require to override a step within the procedure to define the COND parameter for it. You can code sub-parameter in the following format - COND.PROCSTEP=(number,Comparison).

//TPTRICK01 JOB 'TOPICTRICK',MSGCLASS=A,CLASS=C,
//               MSGLEVEL=(1,1),NOTIFY=&SYSUID
//STEP01 EXEC TAXPROC,COND.GO(4,LT)
//....
//....
//

JCL COND - Return Code. 

0 |    Job/Step completed successfully. 
4 |    Minor errors detected but the job/step execution was successful.
8 |    Serious errors detected; Job/step execution likely to fail.
12 |    Serious errors detected; execution impossible.
16 |    Fatal error; job/step execution cannot continue.

Conclusion.

Finally, this marks an end to JCL Tutorial on "COND Parameter in JCL". In this session, you'll learn the basics of the JCL cond parameter, how to use multiple cond parameters in JCL, and cond parameters override in JCL. You'll reinforce your JCL COND parameter knowledge with basic JCL COND  examples (i.e. JCL cond code to bypass step, JCL cond=(0 le), JCL condition codes interview questions, JCL cond=(0, NE), JCL cond=(4, lt)).


Subscribe to Topictrick & Don't forget to press THE BELL ICON to never miss any updates. Also, Please visit mention the link below to stay connected with Topictrick and the Mainframe forum on - 

► Youtube
► Facebook 
► Reddit

Thank you for your support. 
Mainframe Forum™



JCL COND Parameter, COND PARAMETER
JCL COND Param.


Created with Artisteer

No comments:

Post a Comment

New In-feed ads