Showing posts with label cond parameter in jcl. Show all posts
Showing posts with label cond parameter in jcl. Show all posts

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

Sunday, 28 July 2013

JCL Tutorial: COND Parameter in JCL | COND Parameter Examples | [JCL COND Examples].

COND Parameter Example, JCL Tutorial, COND Parameters in JCL

COND Parameter in JCL

Welcome back to today's JCL Tutorial on "JCL COND Parameters" or "COND parameter in JCL". In this session, you'll learn the basics of JCL cond parameters and how you can use the COND parameter in the mainframe jobs for conditional processing. Let's get started with the introduction to JCL.

Agenda - COND Parameters in JCL.
  • What does JCL Stand for?
  • JCL COND Parameters.
  • JOB Return Code and STEP Return Code.
  • COND parameter syntax in JCL.
  • JCL COND Examples.
  • JCL IF-ELSE Condtions.
  • Youtube: How to Process Mainframe Job Conditionally?
  • Conclusion.


What is JCL stands for?


The term JCL stands for "JOB Control Language". It is the command language of the z/OS operating system. JCL actually collates and provides information that identifies the programs to be executed and the data to be processed. JCL tells the operating system what to do. In general, a JCL has three different types of JOB Control Statements. Let's look at the JCL example and it is used to specify datasets and programs.


JCL Tutorial, JCL Example, COND Parameter
JCL Tutorial:- JCL Example


JCL COND Parameter (COND Parameter).


COND Parameters in JCL or simply COND Parameters are used in JCL's for conditional processing. In fact, the COND parameter provides more control over the conditional execution of each job step. You’ll often find that job steps are dependent on one another. If one step ends abnormally, then 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. You can use the COND parameter in both JOB Statements and EXEC statements.

Let's try to understand what is the difference between a JOB Return code and a Step Return Code.

What are the JOB Return Code and STEP return codes?


In the mainframe, JCL's are used to specify the program and datasets that need to be executed to accomplish a specific task, for example, Tax calculation. In JCL, you have different steps and each step passed a code to the z/OS operating system, indicating the status of execution. This code is known as the RETURN Code. 

The RETURN CODE actually indicates if the job has been completed successfully or there is some exception that has occurred. You can easily go through the RETURN CODE and take corrective action. 

Finally, the RETURN Code of the individual step is called as STEP return code, and the RETURN code entire JOB is termed as JOB RETURN CODE. 

Important Note: Step return code A step return code (or just a return code or condition code) indicates whether or not a job step ran successfully. The return code is typically 0 if a step ends normally. The return code can range from 1 to 4095 if the step does not end normally. The return code and what it represents is determined by the program that runs during the process. 


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.

On a single COND parameter, you can include up to eight conditions. Then, if any one 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. 



COND parameter syntax in JCL.


The syntax of the JCL COND Parameter is pretty simple and easy to use. You have to specify the return code followed by the operator. Refer to the following details:

COND=((value,operator)…)

COND Parameter in JCL Example.

Examples: JCL 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.


JCL EXEC COND Parameter.

As you know that JCL COND parameters can be used either on the JOB Statement or EXEC statement or probably on both statements. The COND parameter of an EXEC statement runs return code tests for only its phase in a job. Different tests can be run for each move using EXEC COND parameters. EXEC COND parameters are useful if the same return code has different meanings in different job steps, or if you want to perform different actions depending on which job phase produced the return code.


        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


JCL IF-ELSE construct.


JCL COND parameters enable programmers to control the execution of JCL steps based on return codes. However, you use IF-ELSE construct to execute a piece of logic based on return code. 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.


JCL IF-ELSE Example.


//RTMX01 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

Youtube: How to process Mainframe Job Conditionally.


Conclusion. 


Finally, this marks an end to today's JCL COND Parameter. In this session, you learn how to define and use JCL COND Parameter. You also learn, how to use the COND parameter on the JOB statement and EXEC statements. Don't forget to join us for the next tutorial on "CA7 Command Reference."

►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™

New In-feed ads