Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 Sort numeric fields with trailing spaces sancraig16 SYNCSORT 7 Tue Apr 03, 2018 1:21 am
No new posts Find & Replace string in CA-SORT mrgnndhmk CA Products 1 Fri Mar 30, 2018 12:58 am
No new posts SORT 3 files,extract specific fields ... Kiransr DFSORT/ICETOOL 13 Fri Mar 23, 2018 10:54 am
No new posts How to Generate JCL using Sort naveen katkuri DFSORT/ICETOOL 7 Tue Mar 13, 2018 3:50 pm
No new posts Need better approach to create a sort... Vamshi Veludandi DFSORT/ICETOOL 8 Thu Mar 08, 2018 5:59 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us