MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Date Compare

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Job Control Language(JCL)
View previous topic :: View next topic  
Author Message
sha
Beginner


Joined: 15 Mar 2006
Posts: 2
Topics: 1

PostPosted: Wed Mar 15, 2006 2:15 am    Post subject: Date Compare 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 yesterday's date in JCL.
Only if all 5 dates are equal to yesterday'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
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Mar 15, 2006 8:43 am    Post subject: Reply with quote

sha,

The following JCL will give you the desired results. I assumed that your files has the header record with date as the first record and the pos of the date is at 1 in the format (mm/dd/yyyy)

The first step copies just the header from all the files and reformats the date to (YYYYMMDD) format. In the next step we use that check if it is yesterday's date and set a return code of 4 if the all the 5 dates are equal to yesterday's date. If the Reurn code is 4 then skip the other steps using COND parameter.

Code:
 
//STEP0100 EXEC PGM=SYNCTOOL
//DFSMSG   DD SYSOUT=*
//TOOLMSG  DD SYSOUT=*
//IN1      DD DSN=your input file1,
//            DISP=SHR
//IN2      DD DSN=your input file2,
//            DISP=SHR
//IN3      DD DSN=your input file3,
//            DISP=SHR
//IN4      DD DSN=your input file4,
//            DISP=SHR
//IN5      DD DSN=your input file5,
//            DISP=SHR
//OUT1     DD DSN=&T1,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
//OUT2     DD DSN=&T2,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
//OUT3     DD DSN=&T3,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
//OUT4     DD DSN=&T4,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
//OUT5     DD DSN=&T5,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
//TOOLIN   DD *
  COPY FROM(IN1) TO(OUT1) USING(CTL1)
  COPY FROM(IN2) TO(OUT2) USING(CTL1)
  COPY FROM(IN3) TO(OUT2) USING(CTL1)
  COPY FROM(IN4) TO(OUT2) USING(CTL1)
  COPY FROM(IN5) TO(OUT2) USING(CTL1)
//CTL1CNTL DD *
  OPTION STOPAFT=1
  OUTREC FIELDS=(7,4,   $ YEAR
                 1,2,   $ MONTH
                 4,2)   $ DAY
/*
//STEP0200 EXEC PGM=SORT               
//SYSOUT   DD SYSOUT=*                 
//SORTIN   DD DSN=&T1,DISP=SHR         
//         DD DSN=&T2,DISP=SHR         
//         DD DSN=&T3,DISP=SHR         
//         DD DSN=&T4,DISP=SHR         
//         DD DSN=&T5,DISP=SHR         
//SORTOUT  DD SYSOUT=*                 
//SYSIN    DD * 
//SYSIN    DD *                     
  INCLUDE COND=(1,8,ZD,EQ,&DATE1P-1)
  OPTION NULLOUT=RC4               
  SORT FIELDS=COPY                 
  OUTFIL STARTREC=5                 
/*


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
sha
Beginner


Joined: 15 Mar 2006
Posts: 2
Topics: 1

PostPosted: Wed Mar 15, 2006 9:02 am    Post subject: Date Compare Reply with quote

it works fine for me. thanks a lot kolusu
Back to top
View user's profile Send private message
superk
Advanced


Joined: 19 Dec 2002
Posts: 684
Topics: 5

PostPosted: Wed Mar 15, 2006 3:39 pm    Post subject: Reply with quote

I don't have SYNCSORT, but does &DATE1P-1 really always resolve to the previous day's date, i.e. if &DATE1P is 20060301, then it would resolve to be 20060228?
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Mar 15, 2006 3:43 pm    Post subject: Reply with quote

Quote:

don't have SYNCSORT, but does &DATE1P-1 really always resolve to the previous day's date, i.e. if &DATE1P is 20060301, then it would resolve to be 20060228?

superk,

yes. It considers the leap years and performs the calculation. you can subtract/add upto 9999 days

ex:
Code:

//STEP0100 EXEC PGM=SORT             
//SYSOUT   DD SYSOUT=*               
//SORTIN   DD *                       
20040229                             
//SORTOUT  DD SYSOUT=*               
//SYSIN    DD *                       
 SORT FIELDS=COPY                     
 INCLUDE COND=(1,8,ZD,EQ,&DATE1P-745)
/*     


Current date - 745 days = 29th feb 2004

So the output will have the 1 record.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
superk
Advanced


Joined: 19 Dec 2002
Posts: 684
Topics: 5

PostPosted: Wed Mar 15, 2006 4:48 pm    Post subject: Reply with quote

Cool. 8) Thanks.
Back to top
View user's profile Send private message
js01
Beginner


Joined: 13 Oct 2005
Posts: 84
Topics: 32
Location: INDIA

PostPosted: Mon Mar 20, 2006 8:45 am    Post subject: Reply with quote

hi,
I tried above jcl and getting following error on step2 (successful when 3 files are commented)

WER400A SORTIN IS AN UNINITIALIZED SEQUENTIAL DISK DATA SET


can you please help
thank you
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Mon Mar 20, 2006 8:53 am    Post subject: Reply with quote

js01,

Check this for a detailed explanation of the error WER400A.

Code:

WER400A    ddname IS AN UNINITIALIZED SEQUENTIAL DISK DATA SET                 
                                                                               
           EXPLANATION: The input data set was allocated but never opened for   
           output. Therefore, there is no valid data or end-of-file mark in the
           data set. This condition usually occurs when a program abends and   
           the steps to create the data are bypassed.                           
                                                                               
           ACTION: Write the appropriate data or end-of-file mark in the data   
           set.                                                                 



Hope this helps....

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
js01
Beginner


Joined: 13 Oct 2005
Posts: 84
Topics: 32
Location: INDIA

PostPosted: Mon Mar 20, 2006 11:14 pm    Post subject: Reply with quote

thanks kolusu
its working
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Job Control Language(JCL) All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group