Saturday 10 August 2013

JCL IF/THEN/ELSE/ENDIF Statement Construct.

JCL
JCL IF/THEN/ELSE/ENDIF Statement Construct.


The IF/THEN/ELSE/ENDIF statement construct provides a simple meaning of selectively executing jobs steps and eliminates the need to struggle with the COND parameter.

The IF statement is always followed by a relational-expression and a THEN clause. Optionally, an ELSE clause can follow the THEN clause. An ENDIF statement always follows the ELSE clause, if present, or the THEN clause.
  • The THEN clause specifies the job steps that the system processes when the evaluation of the relational-expression for the IF statement is a true condition. The system evaluates the relational-expression at execution time.
  • The ELSE clause specifies the job steps that the system processes when the evaluation of the relational-expression for the IF statement is a false condition.
  • The ENDIF statement indicates the end of the IF/THEN/ELSE/ENDIF statement construct and must be coded for each construct.
You can nest IF/THEN/ELSE/ENDIF statement constructs up to a maximum of 15 levels. The steps that execute in a THEN clause and an ELSE clause can be another IF/THEN/ELSE/ENDIF statement construct.

You code the construct as follows:

//[name] IF [(]relational-expression[)] THEN [comments] 
              . . action when relational-expression is true  
//[name] ELSE [comments] 
             . . action when relational-expression is false  
//[name] ENDIF [comments]

The IF statement consists of the characters // in columns 1 and 2 and the five fields: name, operation (IF), the relational-expression, the characters THEN, and comments.

The relational-expression can be enclosed in parentheses.
The ELSE statement consists of the characters // in columns 1 and 2 and the three fields: name, operation (ELSE), and comments.

The ENDIF statement consists of the characters // in columns 1 and 2 and the three fields: name, operation (ENDIF), and comments.

Exmple : 1

//   IF  RC > 4  THEN

You can continue relational-expressions on the next JCL statement. Break the relational-expression where a blank is valid on the current statement, and continue the expression beginning in column 4 through 16 of the next statement. Do not put comments on the statement that you are continuing. You can code comments after you have completed the statement.

Example : 2

//TESTCON  IF (RC = 8 | RC = 10 | RC = 12 |
//            RC = 14)  THEN  COMMENTS OK HERE
                   .
                   .

A relational-expression consists of:
  • Comparison operators
  • Logical operators
  • NOT (¬) operators
  • Relational-expression keywords. 
Example : 3

//  IF (STEPA.RC GE 1 AND STEPA.RC LT 4) THEN
//STEP010 EXEC PGM=EMP001 {system execute this step for RC 0 to 4}
//  ELSE
//STEP020 EXEC PGM=EMP002 {system execute this step for RC > than 4}
// ENDIF



JCL
Share http://mainframe-forum.blogspot.com

Created with Artisteer

No comments:

Post a Comment

New In-feed ads