IF THEN ELSE ENDIF - Usage



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

IF THEN ELSE ENDIF - Usage

Postby manesg » Fri Apr 17, 2009 12:18 pm

Hi,

Iam using the following jcl. It uses a REXX program to send mail.
Z/OS 1.8

What it has to do:
Delete datasets mentioned and mail to my mail box about the status.(STEP11 done - use STEP12 to send mail)
If datasets not deleted, mail to my mail box about the status. (STEP11 not done - use STEP13 to send mail)

The code:

//DELMAL JOB (PS),'PS-DELLIB',CLASS=A,MSGCLASS=X,NOTIFY=&SYSUID
//STEP11 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
DELETE MELX.M700PCX.DATA02
DELETE MELX.M700PFX.DATA01
//*
//IFCONO IF (STEP11.RC = 0) THEN
//STEP12 EXEC PGM=IKJEFT01,REGION=6M
//SYSEXEC DD DISP=SHR,DSN=MOPE.ISPF.CMDTRG
//SYSTSPRT DD SYSOUT=*
//SYSPRINT DD DUMMY
//*
//SYSTSIN DD *
%EMAIL / -
SUBJ: Dataset deleted -
ADDR: alex.george@yahoo.com
TEXT: Datasets are deleted. Do check the output at mainframes.
//CONDE ELSE
//IFCONI IF (ABEND | STEP11.RC > 8) THEN
//STEP13 EXEC PGM=IKJEFT01,REGION=6M
//SYSEXEC DD DISP=SHR,DSN=MOPE.ISPF.CMDTRG
//SYSTSPRT DD SYSOUT=*
//SYSPRINT DD DUMMY
//*
//SYSTSIN DD *
%EMAIL / -
SUBJ: Error in Dataset deletion -
ADDR: alisha.taum@yahoo.com
TEXT: Datasets are not deleted. Do check the output at mainframes.
//ENDCONO ENDIF
//ENDCONI ENDIF

The output: (The datasets are not there, so STEP11 returned RC 8, that's fine). But i do not get the mail. Instead i see the following output in my SDSF.

DELMAL STEP11 - STEP WAS EXECUTED - COND CODE 0008
MELX.DELMAL.JOB50768.D0000104.? SYSOUT
MELX.DELMAL.JOB50768.D0000101.? SYSIN
STEP/STEP11 /START 2009106.2328
STEP/STEP11 /STOP 2009106.2328 CPU 0MIN 00.01SEC SRB 0MIN 00.00S
DELMAL STEP12 - STEP WAS NOT RUN BECAUSE OF CONDITIONAL EXPRESSION ON STATEMENT 5
DELMAL STEP12 - STEP WAS NOT EXECUTED.
STEP/STEP12 /START 2009106.2328
STEP/STEP12 /STOP 2009106.2328 CPU 0MIN 00.00SEC SRB 0MIN 00.00S
DELMAL STEP13 - STEP WAS NOT RUN BECAUSE OF CONDITIONAL EXPRESSION ON STATEMENT 12
DELMAL STEP13 - STEP WAS NOT EXECUTED.
STEP/STEP13 /START 2009106.2328

So when i checked for Statements 5 and 12, i see it contains the IF statement. (Shown below:)
1 //DELMAL JOB (PS),'PS-DELLIB',CLASS=A,MSGCLASS=
IEFC653I SUBSTITUTION JCL - (PS),'PS-DELLIB',CL
2 //STEP11 EXEC PGM=IDCAMS
3 //SYSPRINT DD SYSOUT=*
4 //SYSIN DD *
5 //IFCONO IF (STEP11.RC = 0) THEN
6 //STEP12 EXEC PGM=IKJEFT01,REGION=6M
7 //SYSEXEC DD DISP=SHR,DSN=XXX1.ISPF.CMDPROC
8 //SYSTSPRT DD SYSOUT=*
9 //SYSPRINT DD DUMMY
10 //SYSTSIN DD *
11 //CONDE ELSE
12 //IFCONDI IF (ABEND | STEP11.RC > 8) THEN
13 //STEP13 EXEC PGM=IKJEFT01,REGION=6M
14 //SYSEXEC DD DISP=SHR,DSN=XXX1.ISPF.CMDPROC
15 //SYSTSPRT DD SYSOUT=*
16 //SYSPRINT DD DUMMY


Can anyone point me the right direction?
manesg
 
Posts: 22
Joined: Thu Jul 17, 2008 11:16 am
Has thanked: 0 time
Been thanked: 0 time

Re: IF THEN ELSE ENDIF - Usage

Postby swd » Fri Apr 17, 2009 1:03 pm

I think because the return code from the delete is 08 (because the datasets do not exist) STEP12 will not run, but also STEP13 will not run because you code a condition of > 8 (greater than 8). I think you need >= (greater than or equal to 8), then I'm sure it will be OK.
User avatar
swd
 
Posts: 109
Joined: Wed Feb 18, 2009 9:18 pm
Location: UK
Has thanked: 0 time
Been thanked: 0 time

Re: IF THEN ELSE ENDIF - Usage

Postby manesg » Fri Apr 17, 2009 1:57 pm

Thanks swd.
Yes you are correct. I missed out the "=" sign.
Now it does execute STEP13.
But neverthless, i did get RC=08 when the job completes.
The JES Log say:
1.15.29 JOB50787 - --TIMINGS (M
1.15.29 JOB50787 -JOBNAME STEPNAME PROCSTEP RC EXCP CONN TCB SRB
1.15.29 JOB50787 -DELMAL STEP11 08 22 7 .00 .00
1.15.29 JOB50787 -DELMAL STEP12 FLUSH 0 0 .00 .00
1.15.30 JOB50787 -DELMAL STEP13 00 47 15 .00 .00
1.15.30 JOB50787 -DELMAL ENDED. NAME-PS-DELLIB TOTAL TCB CPU TIM
1.15.30 JOB50787 $HASP395 DELMAL ENDED
----- JES2 JOB STATISTICS ------

But i suppose, the "FLUSH" on STEP12 is ok. (Because as said earlier, there are no datasets to be deleted). But the program should give me RC=0, rather than RC=8.
Iam still stuck. Iam still missing something!
manesg
 
Posts: 22
Joined: Thu Jul 17, 2008 11:16 am
Has thanked: 0 time
Been thanked: 0 time

Re: IF THEN ELSE ENDIF - Usage

Postby swd » Fri Apr 17, 2009 2:11 pm

Hi. No, if the datasets do not exist the IDCAMS delete will give a RC=8, so the job will finish with a RC=08 for STEP11. If you want the Delete to give a RC=0 then you can always do this after the delete

//SYSIN DD *
DELETE MELX.M700PCX.DATA02
DELETE MELX.M700PFX.DATA01

IF MAXCC = 8 THEN SET MAXCC = 0
/*

So this will set the return code in STEP11 to zero if there were no datasets to delete, but of course STEP12 will then run, and STEP13 will never run because return code from STEP11 will always be zero whether the datasets exist or not. Not sure if this meet your requirements though, but to answer your question, the job as it stands now will finish with the highest return code of 08 in the delete step, not zero unless you do the above.

I hope this helps you.

Cheers
Steve.
User avatar
swd
 
Posts: 109
Joined: Wed Feb 18, 2009 9:18 pm
Location: UK
Has thanked: 0 time
Been thanked: 0 time

Re: IF THEN ELSE ENDIF - Usage

Postby manesg » Fri Apr 17, 2009 2:25 pm

Addendum -
I tried the reverse
If the dataset is available, and i can delete through this jcl and it returns RC=0. (JCL working perfectly).
But the condition of "dataset not available" results in jcl RC=8.
manesg
 
Posts: 22
Joined: Thu Jul 17, 2008 11:16 am
Has thanked: 0 time
Been thanked: 0 time

Re: IF THEN ELSE ENDIF - Usage

Postby swd » Fri Apr 17, 2009 2:32 pm

A dataset not available at run time will always give you RC=8 if you try to delete it. So you either have to deal with the RC=8, or set it to zero as in the example above.

Is your problem resolved now, or do you need further clarification on this?

Cheers
Steve
User avatar
swd
 
Posts: 109
Joined: Wed Feb 18, 2009 9:18 pm
Location: UK
Has thanked: 0 time
Been thanked: 0 time

Re: IF THEN ELSE ENDIF - Usage

Postby swd » Fri Apr 17, 2009 2:36 pm

A dataset not available at run time will always give you RC=8 if you try to delete it. So you either have to deal with the RC=8, or set it to zero as in the example above.

Is your problem resolved now, or do you need further clarification on this?

Cheers
Steve
User avatar
swd
 
Posts: 109
Joined: Wed Feb 18, 2009 9:18 pm
Location: UK
Has thanked: 0 time
Been thanked: 0 time

Re: IF THEN ELSE ENDIF - Usage

Postby manesg » Fri Apr 17, 2009 3:59 pm

Hi Steve,

Thanks so much.
Yes you are correct.
The code worked as it should be. (I misunderstood earlier, and got clarified after your reply).
Iam not changing anything in the code and now understand it should anyway give RC=08 if no datasets exists to delete.
Its working fine. (So i am not using the SET MAXCC, because that is not the requirement now).
Let me thank you for your reply in short span of time.
I appreciate that.
manesg
 
Posts: 22
Joined: Thu Jul 17, 2008 11:16 am
Has thanked: 0 time
Been thanked: 0 time

Re: IF THEN ELSE ENDIF - Usage

Postby swd » Fri Apr 17, 2009 4:05 pm

Hi manesg
I'm glad it's all sorted now :D .

Cheers
Steve
User avatar
swd
 
Posts: 109
Joined: Wed Feb 18, 2009 9:18 pm
Location: UK
Has thanked: 0 time
Been thanked: 0 time

Re: IF THEN ELSE ENDIF - Usage

Postby Nimbargi » Thu Aug 13, 2009 9:24 pm

Hi Guys, I am new to this Forum.

I have a job that uses 2 steps (STEP1 & STEP2). Each step uses a DB2 utility to delete few records from a DB2 table. Now when any one of the records (either in STEP1 or STEP2 are not found in the respective tables, the particular step returns RC = 7. So Jobb goes fine but with MAXCC = 7.

My requirement is that the job should return MAXCC = 0 even when any of those records are not found. In other words, I need to force MAXCC = 0 when RC = 7 from STEP1/STEP2.

Please help.

Thanks in advance.
Nimbargi
 
Posts: 1
Joined: Thu Aug 13, 2009 9:07 pm
Has thanked: 0 time
Been thanked: 0 time

Next

Return to JCL

 


  • Related topics
    Replies
    Views
    Last post