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

Date compare in JCL


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
punter

New User


Joined: 15 Mar 2006
Posts: 1

PostPosted: Wed Mar 15, 2006 2:43 pm
Reply with quote

hi all,

I have 5 input files. each file is having a header record which contains date. date is in (mm/dd/yyyy) format.

now i have to compare this date(of each file) with previous day's date in JCL. Only if all 5 dates are equal to previous day's date, then continue to execute next steps. Else should skip all the subsequent steps.
Back to top
View user's profile Send private message
manyone

New User


Joined: 09 Mar 2006
Posts: 9

PostPosted: Wed Mar 15, 2006 11:44 pm
Reply with quote

here's a DFSORT solution (tested). (i removed the sortwks and i added dots to indent control cards)


assume at start of day you run this job
//SORT0 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTMSG DD SYSOUT=*
//SORTIN DD *
DUMMY CARD
//SORTOUT DD DSN=TEMP.M4J6060.RUNDATE(+1), CREATE RUNDATE
// UNIT=TEMP,DISP=(,CATLG,DELETE),
// SPACE=(TRK,(1,1),RLSE)
//SYSIN DD *
..INREC FIELDS=(DATE1)
..SORT FIELDS=COPY
//*
at end of job, rundate(0) will contain today as yyyymmdd, and rundate(-1) will contain yesterday



convert yesterdays run date to a record which looks like
RUNDATE,'2006-03-14'
this card will be fed into next step as ddname SYMNAMES

//SORT1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTMSG DD SYSOUT=*
//* YESTERDAYS RUNDATE
//SORTIN DD DISP=SHR,DSN=TEMP.M4J6060.RUNDATE(-1)
//SORTOUT DD DSN=TEMP.M4J6060.W2.DATA(+1), SYMNAMES
// UNIT=TEMP,DISP=(,CATLG,DELETE),
// SPACE=(TRK,(1,1),RLSE)
//SYSIN DD *
..SORT FIELDS=COPY
..OUTFIL OUTREC=(C'RUNDATE,''',5,2,C'-',7,2,C'-',1,4,C'''',80:X)
//*



read the first record of input file (W4.DATA in example) and reformat date as yyyymmdd into V1.DATA if it does NOT match yesterday (ie. if header date matches yesterday, it will NOT be written); create similar step for remaining files to create V2, V3, V4, etc.

//SORT2 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTMSG DD SYSOUT=*
//SYMNAMES DD DISP=SHR,DSN=TEMP.M4J6060.W2.DATA
//SORTIN DD DISP=SHR,DSN=TEMP.M4J6060.W4.DATA
//SORTOUT DD DSN=TEMP.M4J6060.V1.DATA(+1), UNMATCHD HDR
// UNIT=TEMP,DISP=(,CATLG,DELETE),
// RECFM=FB,LRECL=80,BLKSIZE=0,
// SPACE=(TRK,(1,1),RLSE)
//SORTWK01 DD UNIT=SYSDA,SPACE=(CYL,(10,20))
//SORTWK02 DD UNIT=SYSDA,SPACE=(CYL,(10,20))
//SORTWK03 DD UNIT=SYSDA,SPACE=(CYL,(10,20))
//SORTWK04 DD UNIT=SYSDA,SPACE=(CYL,(10,20))
//SORTWK05 DD UNIT=SYSDA,SPACE=(CYL,(10,20))
//SYSIN DD *
..SORT FIELDS=COPY,STOPAFT=1
..OUTFIL INCLUDE=(1,10,CH,NE,RUNDATE),OUTREC=(1,80)
//*



attempt to print the contents of the CONCATENATION of ALL header dates. if file is empty, this returns COND=4. if file is empty, all header dates matched yesterday
//PRINT1 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//INPFILE DD DISP=SHR,DSN=TEMP.M4J6060.V1.DATA
// DD DISP=SHR,DSN=TEMP.M4J6060.V2.DATA (as needed)
//SYSIN DD *
..PRINT IFILE(INPFILE) COUNT(1)
//
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Mar 16, 2006 1:57 am
Reply with quote

punter,

The following Smart DFSORT Trick shows how to include records using relative dates:

www.ibm.com/servers/storage/support/software/sort/mvs/tricks/srtmst03.html#t7r
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu May 11, 2006 4:59 am
Reply with quote

Note that z/OS DFSORT V1R5 PTF UK90007 and DFSORT R14 PTF UK90006 (April, 2006) now provide built-in functions for relative dates like the current date - 1 day or the current date + 30 days. See the following for complete details on using past date constants and future date constants.

Use [URL] BBCode for External Links
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts Need help to append a date&tsp at... DFSORT/ICETOOL 9
Search our Forums:

Back to Top