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™

No comments:

Post a Comment