🖥 JCL
JCL IF/THEN/ELSE/ENDIF
Intermediate 🕑 12 min read
👁 0 views
12
Code Example
## JCL IF/THEN/ELSE/ENDIF
The IF/THEN/ELSE/ENDIF construct provides clearer conditional logic than COND parameter.
### Syntax
\`\`\`jcl
//label IF (condition) THEN
//steps...
//label ELSE
//steps...
//label ENDIF
\`\`\`
### Condition Components
| Component | Description |
|-----------|-------------|
| RC | Return code of previous step |
| ABEND | Abend occurred (TRUE/FALSE) |
| ABENDCC | Abend completion code |
| RUN | Step executed (TRUE/FALSE) |
| stepname.RC | Specific step return code |
### Operators
- Comparison: =, !=, <>, >, <, >=, <=
- Logical: AND, OR, NOT
- Grouping: ( )
### Advantages over COND
1. Positive logic (execute IF true)
2. Clearer syntax
3. ELSE option
4. Can check ABEND status
5. Can nest IF statements
### Important Notes
- ELSE is optional
- Can be nested up to 15 levels
- Steps in ELSE run if condition FALSE or step abended