IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

IF Statement in JCL


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
swapnadeep.ganguly

Active User


Joined: 21 Mar 2007
Posts: 203
Location: India

PostPosted: Thu Dec 13, 2007 4:43 pm
Reply with quote

Hi All,

I have a problem for which I require your help.

I am using IF statement in the JCL. The situation that arises is described under:

"STEP03 or STEP04 or both the steps can return a high code (100 or 50 are the return codes that can be returned by both the steps). Based on the return codes, one of the two files that are created in the program is to be deleted. "

How can I code this situation? Can anyone please help me out?
Back to top
View user's profile Send private message
Agni

New User


Joined: 22 Nov 2007
Posts: 83
Location: Chennai

PostPosted: Thu Dec 13, 2007 5:17 pm
Reply with quote

Hi Swapnadeep,

Please follow the below steps:

1) Have a separate DD for IF condition. That should be after the step03 and Step04.

//JOBCHKB2 IF STEP03.RC = 50 THEN

2) IF the condition is satisfied then you can have separate job step to delete the file (u can use IEFBR14 utility to do the same)

//JOBCHKB2 ELSE

3) If the condition is not satisfied, then do what ever you want in the ELSE part.

//JOBCHKB2 ENDIF

4) Then last step would be ENDIF.


I have given the above example for simple IF-THEN-ELSE. Try giving OR condition and please let me know the result.

Thanks
Agni.
Back to top
View user's profile Send private message
swapnadeep.ganguly

Active User


Joined: 21 Mar 2007
Posts: 203
Location: India

PostPosted: Thu Dec 13, 2007 5:26 pm
Reply with quote

Hi Agni,

Thanks for your response. Actually I would delete the step only if the RC from STEP03/STEP04 is not equal to zero. Thus basically its a nested condition. Actually STEP04 is executed even if the RC from Step03 is not equal to zero.
Back to top
View user's profile Send private message
raak

Active User


Joined: 23 May 2006
Posts: 166
Location: chennai

PostPosted: Thu Dec 13, 2007 6:48 pm
Reply with quote

what is ur condition??

1) delete some file if RC os STEP3 and STEP4 not = 0

or

2) delete the file if RC of STEP3 or STEP4 not = 0
Back to top
View user's profile Send private message
swapnadeep.ganguly

Active User


Joined: 21 Mar 2007
Posts: 203
Location: India

PostPosted: Fri Dec 14, 2007 8:57 am
Reply with quote

My condition is:

Delete some file if RC of STEP3 or STEP4 not = 0
Back to top
View user's profile Send private message
swapnadeep.ganguly

Active User


Joined: 21 Mar 2007
Posts: 203
Location: India

PostPosted: Fri Dec 14, 2007 11:45 am
Reply with quote

Hi All,

I was able to solve the problem. But I think its a crude manner in which I was able to provide the logic. For the reference of all I am pasting the code underneath.

Code:

// IF RC > 0 THEN                                       
//  IF RC = 100 THEN                                     
//DEL01    EXEC PGM=IEFBR14                             
//PROGERR  DD DSN=&NAME..PROGRAM.ERROR,                 
//            DISP=(MOD,DELETE,DELETE),SPACE=(TRK,(1,1))
//  ENDIF                                               
//  IF RC = 50 THEN                                     
//DEL02    EXEC PGM=IEFBR14                             
//SERVERR  DD DSN=&NAME..SERVICE.ERROR,                 
//            DISP=(MOD,DELETE,DELETE),SPACE=(TRK,(1,1))
//  ENDIF                                               
//*                                                     
//STEP05   EXEC PGM=ABORT2                               
//UCC11NR  DD DUMMY                                     
//SYSPRINT DD SYSOUT=*                                   
//SYSOUT   DD SYSOUT=*                                   
//CEEDUMP  DD SYSOUT=*                                   
//SYSUDUMP DD SYSOUT=C                                   
// ENDIF                                                 
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts JOIN STATEMENT PERFORMANCE. DFSORT/ICETOOL 12
No new posts Relate COBOL statements to EGL statement All Other Mainframe Topics 0
No new posts process statement for SUPREC, CMPCOLM... TSO/ISPF 4
No new posts SYNCSORT/ICETOOL JOINKEYS SORT Statem... DFSORT/ICETOOL 13
No new posts DFDSS COPY using Filter REFDT statement JCL & VSAM 2
Search our Forums:

Back to Top