Joined: 10 Nov 2008
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 ?
Joined: 07 Dec 2007
Location: San Jose
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.
//STEP0100 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SYMNAMES DD *
//SORTIN DD *
//SORTOUT DD SYSOUT=*
//SYSIN DD *
The output from the above job is 10 byte file with last month's last day
Hope this helps...