0

There are 3 steps in my JCL:

STEP 1: process STEP 2: NDM STEP 3: DELETE OUTPUT after NDM

What I want to accomplish? I want to execute STEP 3 no matter what the return code of step 2 is.

I tried this: COND=(16,GT) and COND=(16,ST,STEP 2) but it's not doing what I want to do.

piet.t
  • 11,718
  • 21
  • 43
  • 52

2 Answers2

5

Using COND=EVEN has the potential pitfall that the STEP will run even if the previous step ABENDS. Coding COND=(0,GT,STEP2) should allow the step to run but not if there is an ABEND.

Alternately you could use IF/THEN/ELSE/ENDIF coding.

e.g.

//STEP2 EXEC PGM=NDM
//IF STEP2.RC >= 0 THEN
//STEP3 EXEC PGM=???
//ENDIF

or

//STEP2 EXEC PGM=NDM
//IF STEP2.RC GE 0 THEN
//STEP3 EXEC PGM=???
//ENDIF

i.e. either >= or GE can be used.

You may find this helpful IF/THEN/ELSE/ENDIF Statement Construct

or for the COND parameter COND Parameter

MikeT
  • 51,415
  • 16
  • 49
  • 68
4

Try COND=EVEN on your final step’s EXEC statement.

From the documetnation:

COND=EVEN tells MVS to execute this job step EVEN IF a prior step in the same job abends, unless the job is canceled by the MVS operator.

There's also a COND=ONLY:

COND=ONLY tells MVS to execute this job step ONLY IF a prior step in the same job abends.

Explanation of COND:

COND is fairly counter-intuitive. The description is:

If none of these tests is satisfied, the system executes the job step; if any test is satisfied, the system skips the job step on which the COND= parameter is coded.

So your COND=(16,GT) means "If 16 is greater than the return code from any previous steps, don't execute this step". So this step would only execute if ALL the previous steps finished with a RC > 16.

COND=(16,ST,STEP 2) is invalid - ST is not a valid condition. Valid tests are :

EQ - equal                    
LT - less than                
LE - less than or equal to    
NE - not equal                
GT - greater than             
GE - greater than or equal to 

To make a step run, no matter what the condition codes from previous steps are, you could code COND=(0,GT), which means 'if 0 is greater than any previous return code (which it won't be), skip this step.'.

To be safe, you could code:

COND=((0,GT),EVEN)

as EVEN will cause this step to execute even if a previous step ABENDs.

Steve Ives
  • 7,894
  • 3
  • 24
  • 55