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

COND parameter vs IF THEN ELSE


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

New User


Joined: 14 Jan 2016
Posts: 9
Location: INDIA

PostPosted: Fri Jun 17, 2016 5:28 pm
Reply with quote

Hi,

I have a requirement of checking the existense of a file before transmitting it through NDM.

COND Parameter:
In first step I'm checking if the file exists through IDCAMS. If it exists I use the RC=0 of above step to execute step 2 i.e. CDRBATCH.
Cond=(0,NE,STEP01)
It is working fine if the file does not exist i.e. RC=4. However if the file exists, the CDRBATCH step is executed, file is transmitted BUT the inbuilt abender step is also executed and the job abends

IF THEN ELSE:
I'm just using
IF STEP01.RC = 0 THEN
STEP02 >>>> CDRBATCH step
and its working fine for both existing and non-existing file.

Am I missing something here?
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Fri Jun 17, 2016 5:53 pm
Reply with quote

Where is this inbuilt abend step, you haven't shown us

What condition code execution does this step have
Back to top
View user's profile Send private message
Alks

New User


Joined: 14 Jan 2016
Posts: 9
Location: INDIA

PostPosted: Fri Jun 17, 2016 6:16 pm
Reply with quote

Hi expat,

The inbuilt abend step is in the CDRBATCH step.
The jcl goes like this:
//JS005 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD DSN=xxxx.xxxx.controlcard(ABC),
// DISP=SHR
//JS010 EXEC CDRBATCH,COND=(0,NE,JS005)
//CDRBATCH.DMPUBLIB DD DSN=xxxx.xxxx.controlcard,
// DISP=SHR
//SYSIN DD DSN=xxxx.xxxx.controlcard(XYZ),
// DISP=SHR


The control card ABC has LISTCAT ENTRIES(DSN)
i.e. the DSN whose existense is checked.

The control card XYZ has the SNODE PNODE DSNI and DSNO details.
Back to top
View user's profile Send private message
David Robinson

Active User


Joined: 21 Dec 2011
Posts: 199
Location: UK

PostPosted: Fri Jun 17, 2016 6:35 pm
Reply with quote

The CDRBATCH step is not step but a proc. Presumably that contains both the NDM transfer and your "inbuilt abender".

The COND statement that you have shown will apply to all steps in the proc. So either the NDM and abender steps will both run, or neither.

Why don't you have a COND statement on the abender step referring to the NDM step? And why do you even need an abender step?
Back to top
View user's profile Send private message
Alks

New User


Joined: 14 Jan 2016
Posts: 9
Location: INDIA

PostPosted: Fri Jun 17, 2016 6:45 pm
Reply with quote

Hello David, even I'm not very sure as how its happening.

This is what I have in JESMSG
-------------------------------------------------
Job-Name StepName ProcStep Pgm-Name CompCode Sysn
-------- -------- -------- -------- -------- ----
JOBNAME1 JS015 IDCAMS RC=0000 XYZ
-------------------------------------------------
-------------------------------------------------

Job-Name StepName ProcStep Pgm-Name CompCode Sysn
-------- -------- -------- -------- -------- ----
JOBNAME1 JS020 CDRBATCH DMBATCH RC=0000 XYZ
-------------------------------------------------
-------------------------------------------------
Job-Name StepName ProcStep Pgm-Name BelowK AboveM
-------- -------- -------- -------- ------ ------
JOBNAME1 JS020 XIABENDR XIABENDR 7522K 1035M
-------------------------------------------------
JOBNAME1 XIABENDR JS020 - ABEND=S000 U1000 REASON=00000000 661
TIME=07.12.38
-------------------------------------------------
Job-Name StepName ProcStep Pgm-Name CompCode Sysn
-------- -------- -------- -------- -------- ----
JOBNAME1 JS020 XIABENDR XIABENDR Ab-U1000 XYZ
Back to top
View user's profile Send private message
Alks

New User


Joined: 14 Jan 2016
Posts: 9
Location: INDIA

PostPosted: Fri Jun 17, 2016 6:50 pm
Reply with quote

David Robinson wrote:
".

The COND statement that you have shown will apply to all steps in the proc. So either the NDM and abender steps will both run, or neither.

Why don't you have a COND statement on the abender step referring to the NDM step? And why do you even need an abender step?



This is my thinking as well. But I don't think I can access it. I guess this CDRBATCH having abend step is specific to my shop.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Jun 17, 2016 7:00 pm
Reply with quote

Quote:
I guess this CDRBATCH having abend step is specific to my shop.
Since the entire job is specific to your shop, and nowhere else in the world, that is a good guess. If you are thinking this JCL is common, you are incorrect -- it does not exist other places. Other places have NDM, and abend procedures, but what you have is specific to your site.
Back to top
View user's profile Send private message
Alks

New User


Joined: 14 Jan 2016
Posts: 9
Location: INDIA

PostPosted: Fri Jun 17, 2016 7:14 pm
Reply with quote

Thanks Robert for showing my place to me. But when I am using IF ENDIF to control the execution of CDRBATCH, the ABEND step is not getting triggered. This is what confusing me.

//JS005 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD DSN=xxxx.xxxx.xxxx.CTC(ABC),
// DISP=SHR
// IF JS005.RC = 0 THEN
//JS010 EXEC CDRBATCH
//CDRBATCH.DMPUBLIB DD DSN=xxxx.xxxx.xxxx.CTC,
// DISP=SHR
//SYSIN DD DSN=xxxx.xxxx.xxxx.CTC(XYZ),
// DISP=SHR
// ENDIF
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Jun 17, 2016 7:25 pm
Reply with quote

Why would the ABEND step be triggered? You have not posted the JCL for this step, so we have no idea if it has any conditional execution or not. Depending upon the specifics of CDRBATCH, what you are saying could be entirely normal behavior and not a problem in any way.

Your best bet would be to post the CDRBATCH procedure IN ITS ENTIRETY.
Back to top
View user's profile Send private message
Alks

New User


Joined: 14 Jan 2016
Posts: 9
Location: INDIA

PostPosted: Fri Jun 17, 2016 7:47 pm
Reply with quote

The abend condition is COND=(5,GT,CDRBATCH). If my understanding is right when CDRBATCH RC=0, the abend step should get flushed.


XXCDRBATCH PROC
XXCDRBATCH EXEC PGM=DMBATCH,PARM=(YYSLYNN)
XXSTEPLIB DD DSN=xxxx.xxxx.xxxx.LOADLIB,DISP=SHR
XXSYSUDUMP DD SYSOUT=*
//CDRBATCH.DMPUBLIB DD DSN=xxxx.xxxx.xxxx.CTC,
// DISP=SHR
X/DMPUBLIB DD DSN=xxxx.xxxx.xxxx.xxxx,DISP=SHR
XXDMMSGFIL DD DSN=xxxx.xxxx.xxxx.xxxx,DISP=SHR
XXDMNETMAP DD DSN=xxxx.xxxx.xxxx.xxxxx,DISP=SHR
XXDMPRINT DD SYSOUT=*
XXNDMCMDS DD DUMMY USED FOR DEBUGGING ONLY
//SYSIN DD DSN=xxxx.xxxx.xxxx.CTC(XYZ),
// DISP=SHR
X/SYSIN DD DUMMY <-----CONTROL STATEMENTS OVERRIDE THIS
***
XXXIABENDR EXEC PGM=XIABENDR,PARM=1000,COND=(5,GT,CDRBATCH),RD=NR
XXUCC11NR DD DUMMY USED FOR RESTART
***
*********************************************************************
*** CAUSE A USER ABEND 1000 IF RETURN CODE > 4 *
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Fri Jun 17, 2016 8:14 pm
Reply with quote

You should apply the COND to the step you want. In this case, it's the step name is CDRBATCH. So, while calling proc the condition should be COND.CDRBATCH=(0,NE) i.e.
Quote:
//JS010 EXEC CDRBATCH,COND.CDRBATCH=(0,NE)

As said earlier, the possible reason of this behavior is due to the COND being overridden. The 'IF THEN' condition doesn't override the COND and so the step would work as you want it to be.

.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Jun 17, 2016 8:42 pm
Reply with quote

When you start mixing COND with EXEC of PROC as well as programs, you have to expect the unexpected. I suspect what you are seeing is based on this quote from the JCL Reference manual (emphasis added by me):
Quote:
If an EXEC statement calls a cataloged or in-stream procedure, the COND
parameter overrides the COND parameter on or is added to:
v
The EXEC statement named in the procstepname qualifier, which is to the left of
the equals sign. The parameter applies only to the named procedure step. The
EXEC statement can have as many COND.procstepname parameters as the
procedure has steps; each COND parameter must specify a unique
procstepname.
v
All EXEC statements in the procedure if procstepname is not coded. Then the
parameter applies to this job step and to all steps in the called procedure.
Since you apply the COND to the PROC execute without qualifying it, the (0,NE,JS005) is overriding the step-specific COND=(5,GT,CDRBATCH). And using the same name for one of the steps of the PROC as well as the PROC name is a really bad coding practice.
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 INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Using the Jobname parameter in a Qual... ABENDS & Debugging 1
No new posts Demand with DEADLINE TIME parameter CA Products 4
No new posts Option DYNALLOC second parameter. DFSORT/ICETOOL 11
No new posts Writing the output file name from a p... JCL & VSAM 7
Search our Forums:

Back to Top