IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Previous month end date using Sort


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Manny5

New User


Joined: 10 Nov 2008
Posts: 12
Location: Pune

PostPosted: Tue Nov 11, 2008 10:37 am
Reply with quote

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
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Nov 12, 2008 3:00 am
Reply with quote

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

Code:

10/31/2008


Hope this helps...

Cheers
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Populate last day of the Month in MMD... SYNCSORT 2
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
Search our Forums:

Back to Top