Page 1 of 1

Need to Execute JCL step based on date range

PostPosted: Wed Jun 18, 2008 11:49 pm
by claywilly
Hello,

I have a job that runs twice a month. It runs on (or near) the 15th and 30th of the month.

I need to execute one step in the jcl if the date is near the 15th else run the other step.

Can it be done?

Thanks..

Re: Need to Execute JCL step based on date range

PostPosted: Thu Jun 19, 2008 1:21 am
by dick scherrer
Hello,

Sure. Add a new first step to check the current date and set a return-code depending on the date - you may need to code to make sure the job only runs once each half-month. . . .

The existing steps would execute or be bypassed depending on the return code set.

Re: Need to Execute JCL step based on date range

PostPosted: Thu Jun 19, 2008 1:26 am
by MrSpock
I was actually thinking that there are so many different ways this could be approached that it's impossible to even start to mention them all.

Re: Need to Execute JCL step based on date range

PostPosted: Thu Jun 19, 2008 4:37 am
by claywilly
Can one you guys give some examples?

I was thinking of parsing the &sysdate to get the 'day'...

// if (&sysdate(dd) <= '15')
// exec step 1
// else
// exec step2
// endif

??

Re: Need to Execute JCL step based on date range

PostPosted: Thu Jun 19, 2008 6:56 am
by dick scherrer
Hello,

Have you tried this?

I do not recall &sysdate being available in jcl.

You could write a tiny cobol program to get the current date or some other control info and set the return code accordingly. This would give you more flexibility and allow for any needed business rules to be incorporated.

Which sort product is used on your system? If you are not sure, run any sort and post the sysout info.

Re: Need to Execute JCL step based on date range

PostPosted: Thu Jun 19, 2008 9:49 pm
by claywilly
I found out that the IF statement doesn't like the &sysdate parameter. I looked up the IF/THEN/ELSE etc... it doesn't say anything about using system symbols for the parameters.

I doubt that it would work.

Re: Need to Execute JCL step based on date range

PostPosted: Fri Jun 20, 2008 12:43 am
by Bill Dennis
claywilly,

have you tossed out dick's idea of a program?

if so, here's the system I created. You could too.
1. create JOB1 with a step for each date STEP01 to STEP31 (you decide which steps process what)
2. set up JOB2 with an IEBEDIT step and a control card to copy JOB1 to INTRDR including only a single step, STEPnn.
3. set up JOB3 running pgm=EZACFSM1 to read JOB2 and replace 'nn' in the control card with &LDAY and submit to INTRDR (see MVS Init and Tuning Reference for a list of symbols EZACFSM1 will resolve while copying JCL or data files).
4. submit JOB3 which tailors and submits JOB2 which tailors and submits JOB1 containing STEPnn for today's date.

A simple pgm would be less complicated and reusable elsewhere!

Re: Need to Execute JCL step based on date range

PostPosted: Fri Jun 20, 2008 12:50 am
by MrSpock
This is an easy, non-programming method:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN DD *
NOTHING
/*
//T1 DD UNIT=VIO
//T2 DD SYSOUT=*
//TOOLIN  DD    *
COPY FROM(IN) USING(CTL1)
COUNT FROM(T1) EMPTY RC4
/*
//CTL1CNTL DD *
  INREC FIELDS=(DATE)
  OUTFIL FNAMES=T1,INCLUDE=(4,2,CH,LE,C'15')
  OUTFIL FNAMES=T2,SAVE
/*
//*
// IF (S1.RC = 0) THEN
// ** DO DAY <= 15 LOGIC
// ELSE
// ** DO DAY > 15 LOGIC
// ENDIF

Re: Need to Execute JCL step based on date range

PostPosted: Fri Jun 20, 2008 3:40 am
by claywilly
MrSpock wins.

We definitly don't want to write a little program or have 2 or 3 other jobs to execute a simple sort step that just happens once a month.

Thanks MrSpock.

Also, if there is a more 'simpler' way, I am open to that too. But I will give this a try.

claywilly

Re: Need to Execute JCL step based on date range

PostPosted: Fri Jun 20, 2008 10:05 pm
by MrSpock
Sure, but honestly, why would you want to?