Monday, September 26, 2011

JCL : Proceed only if creation date is today


The below job does the following.

  1. First step copies a REXX program to the output file. The REXX program receives a dataset name as an argument and verifies if that dataset is created today. If yes, it generates return code 0, otherwise 4.
  2. The second step in the job executes the REXX program
  3. The 3rd step is executed if the dataset is created today
  4. The 4th step is executed when the dataset is not created today

//useridM   JOB (1212121),'IEHMOVE',CLASS=A,MSGCLASS=Z,NOTIFY=&SYSUID.,
// MSGLEVEL=(2,1)
//GENER0   EXEC PGM=IEBGENER
//SYSUT1   DD DATA,DLM=@@
/* rexx - return rc=0 if today's date                                */
/*        return rc=4 if not todays date                             */
/*        return rc=12 if error                                      */
Parse Upper Arg dsn .
Call outtrap 'stem.'
"listcat ent('" || dsn || "') all"
If rc>0 Then Return 12
Call outtrap 'OFF'
Do a=1 to stem.0 Until create_date <> ""
  Parse Var stem.a . "CREATION--------" create_date .
End
Say "Create date of '"||dsn||"' is "create_date
today = substr(date('S'),1,4)|| "." || substr(date("J"),3)
Say "Today's date is "today
If create_date = today Then
  Return 0
Else
  Return 4
@@
//SYSUT2   DD DISP=(NEW,PASS),DSN=&&CLIST0(TEMPNAME),
//            SPACE=(TRK,(1,1,2),RLSE),UNIT=SYSALLDA,
//            DCB=(LRECL=80,BLKSIZE=0,DSORG=PO,RECFM=FB)
//SYSPRINT DD DUMMY
//SYSIN    DD DUMMY
//*-------------------------------------------------------------------*
//DATECHK  EXEC PGM=IKJEFT01,
// PARM='%TEMPNAME userid.CLIST'
//SYSTSPRT DD DUMMY
//SYSTSIN  DD DUMMY
//SYSEXEC  DD DSN=&&CLIST0,DISP=(OLD,DELETE)
//*-------------------------------------------------------------------*
//*                 Delete temporary profile data set                 *
//*-------------------------------------------------------------------*
//ISTODAY  EXEC PGM=IEBGENER,COND=(0,NE,DATECHK)
//SYSUT1   DD *
  Dataset was created today
//SYSUT2 DD SYSOUT=H
//SYSIN  DD DUMMY
//SYSPRINT DD DUMMY
//NOTTODAY EXEC PGM=IEBGENER,COND=(4,NE,DATECHK)
//SYSUT1   DD *
  Dataset was NOT created today
//SYSUT2 DD SYSOUT=H
//SYSIN  DD DUMMY
//SYSPRINT DD DUMMY
//ERROR    EXEC PGM=IEBGENER,COND=(12,NE,DATECHK)
//SYSUT1   DD *
  date check error
//SYSUT2 DD SYSOUT=H
//SYSIN  DD DUMMY
//SYSPRINT DD DUMMY

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.