DD statements after IF block



JES, JES2, JCL utilities, IDCAMS, Compile & Run JCLs, PROCs etc...

DD statements after IF block

Postby lamino » Thu Mar 23, 2017 6:46 am

I'm trying to have two DD statements after my IF block. I have the following JCL code:
//*                                                            
20 //STEP1 IF (CMPL.RC >= 8 & LKED.RC >= 4) THEN              
21 //STEP1X EXEC PGM=*.LKED1.SYSLMOD                                
22 //S1END  ENDIF
23 //SYSPRINT DD SYSOUT=*            
24 //SYSOUT DD SYSOUT=*              
//*                                                                
 


I get the following errors:

STMT NO. MESSAGE                          
      23 IEFC019I MISPLACED DD STATEMENT  
      24 IEFC019I MISPLACED DD STATEMENT  
 


I wonder if there's a problem with my IF statement. I had no problem using COND, but I'm asked to use IF instead. I cannot move the DD statements on top of the block, since that would not produce the results I want.


(I'd be happy to get some feedback here. Also this is my first post, so if there's something off/missing, just point that out. :) )
lamino
 
Posts: 2
Joined: Thu Mar 23, 2017 6:25 am
Has thanked: 1 time
Been thanked: 0 time

Re: DD statements after IF block

 

Re: DD statements after IF block

Postby Robert Sample » Thu Mar 23, 2017 7:18 am

You need
//STEP1 IF (CMPL.RC >= 8 & LKED.RC >= 4) THEN              
//STEP1X EXEC PGM=*.LKED1.SYSLMOD                                
//SYSPRINT DD SYSOUT=*            
//SYSOUT DD SYSOUT=*  
//S1END  ENDIF 
The DD statements are misplaced in your code because the IF means the EXEC may not be executed, in which case to what step are those DD statements attached? They can't be attached to the step before the IF because there's an EXEC in the IF construct, and they can't be attached to the step after the ENDIF because DD statements must follow (not precede) the EXEC. The ENDIF should ALWAYS follow the last statement in the step(s) being conditionally executed -- not in the middle as you did.
Robert Sample
Global moderator
 
Posts: 3524
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 251 times

Re: DD statements after IF block

Postby lamino » Thu Mar 23, 2017 7:43 am

Thanks! Problem solved. I'm starting to have a better understanding of JCL. :D
lamino
 
Posts: 2
Joined: Thu Mar 23, 2017 6:25 am
Has thanked: 1 time
Been thanked: 0 time


Return to JCL

 


  • Related topics
    Replies
    Views
    Last post