Hi..
Let the input file contains updated date of a record.
I need to extract records which was updated within last 1 year (month). i.e.,. current year (month) -1.
I dont need any date field to be populated in my output file.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
spradeepece,
You need to do a better job of explaining what you want to do before anyone can help you.
What is the form of the date (yyymmdd, yyyyddd, yymmdd, mmddyy, ?).
What is the format of the date (character, zoned decimal, packed decimal, ?).
What is the starting position of the date?
It's not clear what you mean by "I need to extract records which was updated within last 1 year (month). i.e.,. current year (month) -1.". You need to explain what you mean more clearly.
Show an example of the records in your input file (relevant fields only) and what you expect for output. Explain the "rules" for getting from input to output. Give the starting position, length and format of all relevant fields. Give the RECFM and LRECL of the input file.
Thanks. The above mentioned code works fine for leap year. But we cannot hardcode (365/366) for every four years. Is there any other way to solve this out?
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Pradeep,
You could generate a DFSORT Symbol for DATE-366 for leap years or DATE1-365 for non leap years like this. I set up the job to handle leap years from 2008 through 2024 but you can change it as appropriate. If you want to handle every possible leap year forever, you can encode the algorithm for that in DFSORT control statements yourself.
Code:
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
RECORD
/*
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN DD *
OPTION COPY
INREC IFOUTLEN=80,
IFTHEN=(WHEN=INIT,BUILD=(DATE1)),
* If leap year, use DATE1-366
IFTHEN=(WHEN=(1,4,SS,EQ,
* Set up leap years you want to handle.
C'2008,2012,2016,2020,2024'),
BUILD=(C'TDATE,''',DATE1(-)-366,C'''')),
* If not leap year, use DATE1-365
IFTHEN=(WHEN=NONE,
BUILD=(C'TDATE,''',DATE1(-)-365,C''''))
/*
//S2 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD DSN=... input file
//SORTOUT DD DSN=... output file
//SYSIN DD *
OPTION COPY
INCLUDE COND=(1,10,CH,GT,TDATE)
/*
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
gcicchet,
Point taken. Here is the updated version which evaluates if the current date is greater than or equal to feb 29. If the date is less than feb 29 and even though the year is a leap year we subtract 365 days from the current date. If the date is greater than or equal to feb 29 and the year is a leap year then we subtract 366 days from the current date