MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Subtracting days from a date in Syncsort

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
prog_mario
Beginner


Joined: 08 Sep 2007
Posts: 86
Topics: 27

PostPosted: Sun Nov 22, 2009 5:44 pm    Post subject: Subtracting days from a date in Syncsort Reply with quote

I'm trying to fix a condition in a sort but I having
difficulty on it as I hardly ever use such logic in sort.
In my input file there's a field that contains a date '20081110'.
In the sort I have to subtract 60 days from this date.
What I need to know is how to let the Sort to treat this information as a
date.
The command I'm trying to build is:
Code:

IFTHEN=(WHEN=(13,8,CH,NE,C'00010101'),
 OVERLAY=(13:13,8,??????? -60))


when that field (position 13, length 8 ) is different from '00010101' I
need to subtract 60 days from it and overlay the output starting at
position 13 with the result of this subtraction.
Hope someone can help, if possible.
Below is the code in which I'll insert this new command.
Code:

  JOINKEYS FILE=F1,FIELDS=(1,12,A)                                     
  JOINKEYS FILE=F2,FIELDS=(1,12,A)                                     
  REFORMAT FIELDS=(F1:1,12,                           
                   F1:13,4,                           
                   F1:18,2,                           
                   F1:21,2,                             
                   F1:23,4,                           
                   F1:28,2,                           
                   F1:31,2)                             
  INREC FIELDS=(1,12,                                 
                13,8,ZD,MAX,                 
                21,8,ZD,                                 
                ZD,LENGTH=8)           
  SORT FIELDS=COPY                                                     
  OUTREC IFTHEN=(WHEN=(13,8,CH,EQ,C'00010101'),
                 OVERLAY=(13:&DATENS(4MD)-60)),  DATE MINUS 60 DAYS

               IFTHEN=(WHEN=(13,8,CH,NE,C'00010101'),
                 OVERLAY=(13: NEW COMMAND WILL GO HERE)
Back to top
View user's profile Send private message
Brian Wood
Beginner


Joined: 14 Jan 2009
Posts: 37
Topics: 0
Location: USA

PostPosted: Mon Nov 23, 2009 3:21 pm    Post subject: Reply with quote

prog_mario:

At this time, SyncSort does not have a special function to perform arithmetic on input date fields.
_________________
Brian Wood
SyncSort Mainframe Product Services
201-930-8260
zos_tech@syncsort.com
Back to top
View user's profile Send private message Send e-mail
prog_mario
Beginner


Joined: 08 Sep 2007
Posts: 86
Topics: 27

PostPosted: Mon Nov 23, 2009 6:52 pm    Post subject: Thanks. Reply with quote

What a pitty, Brian.
So I'll have to find out another way to treat this dates.
Thanks a lot.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Mon Nov 23, 2009 8:57 pm    Post subject: Reply with quote

prog_mario,

Just for the record, With z/OS DFSORT V1R5 PTF UK51706 or z/OS DFSORT V1R10 PTF UK51707 (Nov, 2009), DFSORT now supports the JOINKEYS as well as date conversion functions(TOGREG,TOJUL) which can perform date arithmetic and give you the desired results in one pass like shown below:

Code:

//SYSIN    DD *                                               
  JOINKEYS FILE=F1,FIELDS=(1,12,A)                             
  JOINKEYS FILE=F2,FIELDS=(1,12,A)                             
  REFORMAT FIELDS=(F1:1,12,                                   
                   F1:13,4,                                   
                   F1:18,2,                                   
                   F1:21,2,                                   
                   F1:23,4,                                   
                   F1:28,2,                                   
                   F1:31,2)                                   
  SORT FIELDS=COPY     
                                       
  INREC IFOUTLEN=20,IFTHEN=(WHEN=INIT,                         
  BUILD=(1,12,13,8,ZD,MAX,21,8,ZD,ZD,LENGTH=8)),               
  IFTHEN=(WHEN=(13,8,CH,EQ,C'00010101'),OVERLAY=(13:DATE1-60)),
  IFTHEN=(WHEN=(13,8,CH,NE,C'00010101'),                       
  OVERLAY=(21:13,8,Y4T,TOJUL=Y4T),HIT=NEXT),                   
  IFTHEN=(WHEN=(21,8,CH,GT,C' '),                             
  OVERLAY=(25:25,3,ZD,SUB,+60,ZD,LENGTH=3),HIT=NEXT),         
  IFTHEN=(WHEN=(25,3,ZD,LE,0),                                 
  OVERLAY=(28:21,4,ZD,SUB,+1,EDIT=(TTTT),C'1231',             
           28,8,Y4T,TOJUL=Y4T,                                 
           21:36,4,40,3,ZD,ADD,25,3,ZD,EDIT=(TTT),             
           13:21,7,Y4T,TOGREG=Y4T)),                           
  IFTHEN=(WHEN=(25,3,ZD,GT,0),                                 
  OVERLAY=(13:21,7,Y4T,TOGREG=Y4T))                           
//*


For complete details on JOINKEYS and the new date conversion functions available with the Nov, 2009 DFSORT PTF, see:

http://www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000174
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Mon Oct 25, 2010 12:16 pm    Post subject: Reply with quote

prog_mario,

With PTF UK90025 for z/OS DFSORT V1R10 and PTF UK90026 for z/OS DFSORT V1R12(Oct, 2010), DFSORT now supports date arithmetic which can add/subtract days, months or years to a given date like shown below.

Code:

//STEP0100 EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                   
//SORTIN   DD *                                           
20100228 - NON LEAP YEAR DATE                             
20080229 - LEAP YEAR DATE                                 
20070229 - INVALID DATE                                   
//SORTOUT  DD SYSOUT=*                                   
//SYSIN    DD *                                           
  SORT FIELDS=COPY                                       
  OUTREC OVERLAY=(40:1,8,Y4T,SUBDAYS,+60,TOGREG=(Y4T(-)))
//*


The output from the above job is

Code:

20100228 - NON LEAP YEAR DATE          2009-12-30
20080229 - LEAP YEAR DATE              2007-12-31
20070229 - INVALID DATE                **********


For complete details of date arithmetic functions and other new functions see "User Guide for DFSORT PTFs UK90025 and UK90026" paper (sortugph.pdf) at:

http://www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000242
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
prog_mario
Beginner


Joined: 08 Sep 2007
Posts: 86
Topics: 27

PostPosted: Tue Oct 26, 2010 10:25 am    Post subject: Reply with quote

Thanks again Kolusu. I'll keep that in my files. Very Happy
_________________
The more I learn, the more I want to learn.
Back to top
View user's profile Send private message
mangsk
Beginner


Joined: 05 Jun 2004
Posts: 46
Topics: 18

PostPosted: Wed Mar 14, 2012 8:43 am    Post subject: Reply with quote

Quote:

Posted: Mon Nov 23, 2009 3:21 pm

prog_mario:
At this time, SyncSort does not have a special function to perform arithmetic on input date fields.
_________________
Brian Wood
SyncSort Mainframe Product Services
201-930-8260
zos_tech@syncsort.com


Brian, Alissa,
It is over 2 years since the original post. Does Syncsort support the arithmetic function on input date fields now?
_________________
Regards,
Mangsk
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group