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 

How to add years to date in format CCYY-MM-DD using DFSORT?

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


Joined: 01 Jun 2012
Posts: 18
Topics: 7

PostPosted: Thu Aug 27, 2015 8:01 am    Post subject: How to add years to date in format CCYY-MM-DD using DFSORT? Reply with quote

How to add years to date in format CCYY-MM-DD ?

input is like this:
Code:

1233 2009-01-01
1234 2010-01-28
3456 2015-03-31

output :
if the date is less than 2010-01-01 then suffix the date 2010-01-01 with input record. if it is greater than 2010--01-01 then add 3 years to existing year and suffix the date
Code:

1233 2009-01-01 2010-01-01
1234 2010-01-28 2013-01-28
3456 2015-03-31 2018-03-31

Thanks
SRI
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Aug 27, 2015 10:55 am    Post subject: Reply with quote

SRI123,

Assuming your input file has an lrecl of 80 and recfm=fb, use the following DFSORT JCL
Code:

//STEP0100 EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                   
//SORTIN   DD *                                           
1233 2009-01-01                                           
1234 2010-01-28                                           
3456 2015-03-31                                           
//SORTOUT  DD SYSOUT=*                                   
//SYSIN    DD *                                           
  OPTION COPY                                             
  INREC IFOUTLEN=80,                                     
  IFTHEN=(WHEN=INIT,OVERLAY=(81:6,10,UFF,M11,LENGTH=8)), 
  IFTHEN=(WHEN=(81,8,ZD,LT,20100101),                     
  OVERLAY=(17:C'2010-01-01')),                           
  IFTHEN=(WHEN=NONE,                                     
  OVERLAY=(17:81,8,Y4T,ADDYEARS,+3,TOGREG=Y4T(-)))       
//* 

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
SRI123
Beginner


Joined: 01 Jun 2012
Posts: 18
Topics: 7

PostPosted: Thu Aug 27, 2015 12:10 pm    Post subject: Reply with quote

Hi Kolusu

Thanks for reply. If I have input record has some more field and I want to take that field to some other position in output file. So do I need to change INREC to OUTREC?
Code:

1233 2009-01-01 ABCD123
1234 2010-01-28 ABCD123
3456 2015-03-31 ABCD123

My output should be like this
Code:

1233 2009-01-01 2010-01-01 ABCD123
1234 2010-01-28 2013-01-28 ABCD123
3456 2015-03-31 2018-03-31 ABCD123

Thanks
SRI
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Aug 27, 2015 12:43 pm    Post subject: Reply with quote

SRI123 wrote:
Hi Kolusu

Thanks for reply. If I have input record has some more field and I want to take that field to some other position in output file. So do I need to change INREC to OUTREC?


Sri123,

Please do not waste my time as well as your time. How hard is to show the complete requirement? People help out of their spare time and you can't expect them to go back and re-work on YOUR moving target requirement again and again.

Please answer ALL of the following questions.

1. What is the LRECL and RECFM of the input file ?
2. What is the LRECL and RECFM of the desired output file?
3. What is the position and format of the input date field?
4. What is the position and format of the output date field?
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
SRI123
Beginner


Joined: 01 Jun 2012
Posts: 18
Topics: 7

PostPosted: Thu Aug 27, 2015 12:49 pm    Post subject: Reply with quote

Sorry Kolusu

1. What is the LRECL and RECFM of the input file ? - 80 bytes
2. What is the LRECL and RECFM of the desired output file? - 80 bytes
3. What is the position and format of the input date field? - 6
4. What is the position and format of the output date field? - 17
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Aug 27, 2015 1:00 pm    Post subject: Reply with quote

SRI123 wrote:
Sorry Kolusu

1. What is the LRECL and RECFM of the input file ? - 80 bytes
2. What is the LRECL and RECFM of the desired output file? - 80 bytes
3. What is the position and format of the input date field? - 6
4. What is the position and format of the output date field? - 17


Sri123,

Once again if your input is 80 bytes and output is also 80 bytes, how are you going to add a new date field? Since you are adding the new date field at position 17 and shifting the contents of position of 17 to the right, are you deleting the last 10 bytes? in order to account for the new date field?
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
SRI123
Beginner


Joined: 01 Jun 2012
Posts: 18
Topics: 7

PostPosted: Thu Aug 27, 2015 2:27 pm    Post subject: Reply with quote

Hi Kolusu
Even thou input is 80bytes, only 1st 40 bytes has data .
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Aug 27, 2015 4:18 pm    Post subject: Reply with quote

SRI123 wrote:
Hi Kolusu
Even thou input is 80bytes, only 1st 40 bytes has data .


Sri123,

Use the following DFSORT control cards

Code:

//SYSIN    DD *                                                       
  OPTION COPY                                                         
  INREC IFOUTLEN=80,                                                 
  IFTHEN=(WHEN=INIT,BUILD=(1,15,11X,16,54,81:6,10,UFF,M11,LENGTH=8)),
  IFTHEN=(WHEN=(81,8,ZD,LT,20100101),                                 
  OVERLAY=(17:C'2010-01-01')),                                       
  IFTHEN=(WHEN=NONE,                                                 
  OVERLAY=(17:81,8,Y4T,ADDYEARS,+3,TOGREG=Y4T(-)))                   
//*

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
SRI123
Beginner


Joined: 01 Jun 2012
Posts: 18
Topics: 7

PostPosted: Fri Aug 28, 2015 2:44 am    Post subject: Reply with quote

Thank you Kolusu...
Back to top
View user's profile Send private message
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