View previous topic :: View next topic |
Author |
Message |
SRI123 Beginner
Joined: 01 Jun 2012 Posts: 18 Topics: 7
|
Posted: Thu Aug 27, 2015 8:01 am Post subject: How to add years to date in format CCYY-MM-DD using DFSORT? |
|
|
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 |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Thu Aug 27, 2015 10:55 am Post subject: |
|
|
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 |
|
|
SRI123 Beginner
Joined: 01 Jun 2012 Posts: 18 Topics: 7
|
Posted: Thu Aug 27, 2015 12:10 pm Post subject: |
|
|
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 |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Thu Aug 27, 2015 12:43 pm Post subject: |
|
|
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 |
|
|
SRI123 Beginner
Joined: 01 Jun 2012 Posts: 18 Topics: 7
|
Posted: Thu Aug 27, 2015 12:49 pm Post subject: |
|
|
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 |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Thu Aug 27, 2015 1:00 pm Post subject: |
|
|
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 |
|
|
SRI123 Beginner
Joined: 01 Jun 2012 Posts: 18 Topics: 7
|
Posted: Thu Aug 27, 2015 2:27 pm Post subject: |
|
|
Hi Kolusu
Even thou input is 80bytes, only 1st 40 bytes has data . |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Thu Aug 27, 2015 4:18 pm Post subject: |
|
|
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 |
|
|
SRI123 Beginner
Joined: 01 Jun 2012 Posts: 18 Topics: 7
|
Posted: Fri Aug 28, 2015 2:44 am Post subject: |
|
|
Thank you Kolusu... |
|
Back to top |
|
|
|
|