I would like to compare a year in a file (columns 1-2) again the current-date, todays-date, the run-date, system-date or whatever it is called in dfsort. If the files date is less that 3 years from the system-date year, put it in one file, or else put it in another.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Quote:
If the files date is less that 3 years from the system-date year
That requirement is a little confusing. Am example of input and output would have helped. However, here's a DFSORT job that should give you the idea of how to do this kind of thing.
Code:
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SYMNAMES DD *
YR,S'&YR2'
/*
//SORTIN DD *
RECORD
/*
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN DD *
OPTION COPY
* Create a DFSORT Symbol as:
* TARG_YR,Y'xx'
* where xx is current_yy-3
INREC OVERLAY=(51:YR,
1:C'TARG_YR,Y''',51,2,ZD,SUB,+3,EDIT=(TT),C'''')
/*
//S2 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD *
98
99
00
01
02
03
04
05
06
07
/*
//OUT1 DD SYSOUT=*
//OUT2 DD SYSOUT=*
//SYSIN DD *
OPTION COPY,Y2PAST=1980
* Use the TARG_YR symbol in INCLUDE.
OUTFIL FNAMES=OUT1,INCLUDE=(1,2,Y2C,LT,TARG_YR)
OUTFIL FNAMES=OUT2,SAVE
/*
OUT1 would have:
98
99
00
01
02
03
OUT2 would have:
04
05
06
07
If that's not what you want, then please explain more clearly what you want and show an example of input and expected output.
I have an unsorted input file with YYMMDDxxxxxxxxxxxx for the records.
Like:
941025xxxxxxxxxxxxxx
061003xxxxxxxxxxxxxx
970314xxxxxxxxxxxxxx
070809xxxxxxxxxxxxxx
The current-date or system-date is now "2007-10-16 14:50"
Records 2 and 4 have a 'difference year' that is not greater than 3
2007-2006=1
2007-2007=0
Records 2 and 4 go into output file 1.
Records 1 and 3 go into output file 2.
2007-1994=13
2007-1997=10
Of course I will compare the month and day as well, but I was keeping it simple.
Thank you so much for your help. I know it will be simple if ICEMAN can access the system-date/time. But I dont know what format it will look like, or how to store it for the compare.
Of course I will compare the month and day as well, but I was keeping it simple.
Thank you so much for your help. I know it will be simple if ICEMAN can access the system-date/time. But I dont know what format it will look like, or how to store it for the compare.
I set up the solution to just handle the 2-digit year date as you requested. Using the entire date would require a different solution. If you want help with that, you need to explain exactly what you want to do in terms of comparing the month and day as well.
Note: "Keeping it simple" by providing only a part of the requirement isn't a good strategy on this board. You give a piece of your requirement - I show you how to do it - then you come back and say that wasn't really my requirement so now I need this. That just wastes time.