Manny5
New User
Joined: 10 Nov 2008 Posts: 12 Location: Pune
|
|
|
|
Hi,
We can fetch system date using sort step. What i need to know is.
Is there way i can have previous month end date if i run my jcl today.
for example if my Job runs on 11/10/2008 , i want it to return
10/31/2008. Is there way i can do it in JCL ?
Thanks,
Manny |
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Manny,
The following DFSORT JCL will give you the desired results. We use 3 system symbols.
1. Jday will give the julian day number ie. Nov11 is 316th day of the year
2. Mday will give the day of the month ie NOV11 is 11th of the month
3. DY2 will give the 2 digit year ie. 08
we subtract the MDAY from JDAY which will result in the last day of the prev month in julian format.ie. 316-11=305 which is oct31 and is 305th day of the year. We need to convert this back to gregorian format which can be done using the DT1 conversion. DT1 format requires the input to be packed decimal format with the following format X'01YYDDDC'. we already got the YY and DDD part of it. So just append x'01' and convert the number into packed decimal format and use that result as input to DT1 which will convert the julian date back to gregorian format.
Code: |
//STEP0100 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SYMNAMES DD *
JDAY,S'&LJDAY'
MDAY,S'&LDAY'
DY2,S'&LYR2'
//SORTIN DD *
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:JDAY,MDAY,DY2)),
IFTHEN=(WHEN=INIT,OVERLAY=(88:81,3,ZD,SUB,84,2,ZD,M11,LENGTH=3)),
IFTHEN=(WHEN=INIT,OVERLAY=(91:X'01',86,5,ZD,TO=PD,LENGTH=3)),
IFTHEN=(WHEN=INIT,OVERLAY=(81:91,4,DT1,EDIT=(TTTTTTTT)))
SORT FIELDS=COPY
OUTREC BUILD=(85,2,C'/',87,2,C'/',81,4)
/* |
The output from the above job is 10 byte file with last month's last day
Hope this helps...
Cheers |
|