Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Previous month end date using Sort

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Previous month end date using Sort
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    Post subject: Reply to: Previous month end date using Sort
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to change 'K' or 'M' use Sort vice_versa DFSORT/ICETOOL 5 Thu May 18, 2017 7:11 am
No new posts Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
This topic is locked: you cannot edit posts or make replies. SORT trick needed bshkris SYNCSORT 6 Tue May 02, 2017 4:35 am
No new posts LISTIDR compiled date/time jerryte IBM Tools 3 Thu Apr 20, 2017 7:37 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us