IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

ADDMONS function


IBM Mainframe Forums -> SYNCSORT
Post new topic   This topic is locked: you cannot edit posts or make replies.
View previous topic :: View next topic  
Author Message
rnimmala

New User


Joined: 08 Nov 2019
Posts: 10
Location: INDIA

PostPosted: Fri Nov 08, 2019 8:55 pm
Reply with quote

Hi All,
We are using SYNCSORT and ADDMONS function is not working if term(months) is 12 and result falls in leap year. But it is working fine if months(term) is 1 to 11 months.

e.g 20190331 + 11= 20200229 (as expected).
20190228+ 12 = 20200228 ( expecting 29)
20180228+24 = 20200228 (expecting 29)
20180331 +23 = 20200229 (as expected)

Please help me to fix the issue.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2019
Location: USA

PostPosted: Fri Nov 08, 2019 9:23 pm
Reply with quote

rnimmala wrote:
Hi All,
We are using SYNCSORT and ADDMONS function is not working if term(months) is 12 and result falls in leap year. But it is working fine if months(term) is 1 to 11 months.

e.g 20190331 + 11= 20200229 (as expected).
20190228+ 12 = 20200228 ( expecting 29)
20180228+24 = 20200228 (expecting 29)
20180331 +23 = 20200229 (as expected)

Please help me to fix the issue.


It is successfully working for anyone except yourself...

Any source code, please!!!!
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Nov 08, 2019 9:29 pm
Reply with quote

Have you contacted the vendor? If not, get started contacting them! It is their product, and if you think it is not working correctly, they need to know that.
Back to top
View user's profile Send private message
rnimmala

New User


Joined: 08 Nov 2019
Posts: 10
Location: INDIA

PostPosted: Fri Nov 08, 2019 9:34 pm
Reply with quote

Apologies if I am wrong.I have posted this after testing.will provide source code on Monday.
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1742
Location: Tirupur, India

PostPosted: Fri Nov 08, 2019 9:39 pm
Reply with quote

Interesting problem, I too get the same error as TS with below JCL

Code:
//SORT     EXEC  PGM=SORT                   
//SYSOUT   DD    SYSOUT=*                   
//SORTIN   DD    DISP=SHR,DSN=WELLS.SORTIN 
//SORTOUT  DD    DISP=OLD,DSN=WELLS.SORTOUT
//SYSIN    DD *                             
 SORT FIELDS=COPY                           
 INREC BUILD=(1,8,Y4T,ADDMONS,+12,TOGREG=Y4T)
/*                                           


Input:
20190228
Output:
20200228

We are on Syncsort/MFX 2.1 - TPF 6.

Syncsort support would be able to help you with it.
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1742
Location: Tirupur, India

PostPosted: Fri Nov 08, 2019 9:46 pm
Reply with quote

Hi sergeyken, what version of Syncsort are you on?
Knowing that would let us know, if it has been fixed in a later release.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2019
Location: USA

PostPosted: Fri Nov 08, 2019 10:17 pm
Reply with quote

20190228 + 12 month = 20200228

This is absolutely correct!
Exactly as it is
20190201 + 12 month = 20200201
20190210 + 12 month = 20200210
20190330 + 12 month = 20200330

To get 20200229 you would need to apply extra function, like this example
Code:
//*==========================================================
//SORT     EXEC  PGM=SORT                                   
//SYSOUT   DD    SYSOUT=*                                   
//SORTIN   DD    *                                           
20190228                                                     
20190201                                                     
20190210                                                     
20190330                                                     
20190331                                                     
//SORTOUT  DD    SYSOUT=*                                   
//SYSIN    DD *                                             
 SORT FIELDS=COPY                                           
 INREC IFTHEN=(WHEN=INIT,                                   
               BUILD=(1,8,                                   
                    X,1,8,Y4T,ADDMONS,+12,TOGREG=Y4T)),     
        IFTHEN=(WHEN=INIT,                                   
                OVERLAY=(19:10,8,Y4T,LASTDAYM,TOGREG=Y4T))   
//*==========================================================


Code:
********************************* TOP OF DATA *******
20190228 20200228 20200229                           
20190201 20200201 20200229                           
20190210 20200210 20200229                           
20190330 20200330 20200331                           
20190331 20200331 20200331                           
******************************** BOTTOM OF DATA *****
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2019
Location: USA

PostPosted: Fri Nov 08, 2019 10:30 pm
Reply with quote

P.S.
ADDMONS doesn't need to touch the DAY-part at all, whatever it was. It may either verify the date correctness, or not - but it cannot affect the way of adding pure months.

It only converts "long month day" to "short month day", and reduces the excessive day number for any short month.
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1742
Location: Tirupur, India

PostPosted: Fri Nov 08, 2019 10:38 pm
Reply with quote

Now it makes sense, The function need not necessarily generate the last day of the month. Thank you.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Sat Nov 09, 2019 12:41 am
Reply with quote

This looks to a bug and should be reported to SYNCSORT.

If you try to add it in the same year ( of the leap year) then it works but when it is other than the leap year and when ADDMONS falls into leap year it don't work.

If you refer the manual it is clearly stated it will consider leap year when ADDMONS or SUBMONS used with an example.
Code:

//*                                                           
//SORT     EXEC  PGM=SORT                                     
//SYSOUT   DD    SYSOUT=*                                     
//SORTIN   DD    *                                             
20200131                                                       
//SORTOUT  DD    SYSOUT=*                                     
//SORTLIST DD    SYSOUT=*                                     
//SYSIN    DD *                                               
 SORT FIELDS=COPY                                             
 INREC IFTHEN=(WHEN=INIT,                                     
               BUILD=(1,8,                                     
                    X,1,8,Y4T,ADDMONS,+1,TOGREG=Y4T)),         
        IFTHEN=(WHEN=INIT,                                     
                OVERLAY=(19:10,8,Y4T,LASTDAYM,TOGREG=Y4T))     

output
Code:
20200131 20200229 20200229


SYNCSORT Documentation ( May not be the latest one). Refer page# 201
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2019
Location: USA

PostPosted: Sat Nov 09, 2019 7:05 pm
Reply with quote

Do you plan to calculate
20190228 + 1month = 20190331 ?
20190228 + 13month = 20200331 ???

This is nonsense...
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Sat Nov 09, 2019 7:12 pm
Reply with quote

Your are free to try and convince yourself and create your own manual and discard what Syncsort has to say about their products.
Back to top
View user's profile Send private message
rnimmala

New User


Joined: 08 Nov 2019
Posts: 10
Location: INDIA

PostPosted: Sat Nov 09, 2019 7:20 pm
Reply with quote

HI,
All I am saying A⁸DDMONS has issue with12months.My requirement is set the month end date. E.g if I add 1 month 20200131 the function returns me 20200229..so function works perfectly for 01 to 11 months
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Sat Nov 09, 2019 7:25 pm
Reply with quote

You need to discuss that with Syncsort and give them a chance to help on that and meanwhile use LASTDAYM when it is 12 M. The manual that I shared say's it will consider Leap year but unfortunately it don't when its ONLY and ONLY 12 months. Lesser or greater than 12 will work correctly.

You can send an email to support@syncsort.com.
Back to top
View user's profile Send private message
rnimmala

New User


Joined: 08 Nov 2019
Posts: 10
Location: INDIA

PostPosted: Sat Nov 09, 2019 7:28 pm
Reply with quote

Hi,
I don't know whom to contact from Syncsort team.Before opening this post I have written email to Alissa if it known issue then I can use LASYDAYM.I am waiting for the response.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Sat Nov 09, 2019 7:28 pm
Reply with quote

Quote:
My requirement is set the month end date


unfortunately then, ADDMONS is not the way ...

the change in the day part will occur only when the source day is greater that the number of days in the destination month ,
in which case the day will be the last day of the destination month
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2019
Location: USA

PostPosted: Sat Nov 09, 2019 8:02 pm
Reply with quote

After reading the manual, and applying some common sense, it’s getting clear that:
20200131 + 1month = 20200229
20200129 + 1month = 20200229
20200128 + 1month = 20200228

20190131 + 1month = 20190228
20190129 + 1month = 20190228
20190128 + 1month = 20190228
20190127 + 1month = 20190227

20190131 + 13month = 20200229
20190128 + 13month = 20200228
20190228 + 12month = 20200228

Etc.

Just apply common sense...
Back to top
View user's profile Send private message
rnimmala

New User


Joined: 08 Nov 2019
Posts: 10
Location: INDIA

PostPosted: Sat Nov 09, 2019 8:09 pm
Reply with quote

I am decided go with LASTDAYM after adding the term.Thank you all for your help.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2019
Location: USA

PostPosted: Sat Nov 09, 2019 8:15 pm
Reply with quote

Rohit Umarjikar wrote:
Your are free to try and convince yourself and create your own manual and discard what Syncsort has to say about their products.

I have carefully re-read the manual. There is nothing about adding extra day after adding any months. Only short months are truncated to the last day of that month!!!

Again: try to apply common sense.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2019
Location: USA

PostPosted: Sat Nov 09, 2019 8:21 pm
Reply with quote

rnimmala wrote:
HI,
All I am saying A⁸DDMONS has issue with12months.My requirement is set the month end date. E.g if I add 1 month 20200131 the function returns me 20200229..so function works perfectly for 01 to 11 months

Try this:
20200128 + 1month = 20200228, but not 20200229
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2019
Location: USA

PostPosted: Sat Nov 09, 2019 8:25 pm
Reply with quote

Right now I don’t have access to the system, but I suppose that maybe
20190228 + 1year = 20200229 ?

Try this, please...
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Sat Nov 09, 2019 8:38 pm
Reply with quote

Quote:
20190228 + 1year = 20200229 ?


NOPE ...

20200228 is a valid date, no reason to adjust anything

but on the other side

20200229 + 12 months ==> 20210228
as You already pointed out icon_smile.gif

time to lock the topic ...
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Sat Nov 09, 2019 8:49 pm
Reply with quote

sergeyken wrote:
Rohit Umarjikar wrote:
Your are free to try and convince yourself and create your own manual and discard what Syncsort has to say about their products.

I have carefully re-read the manual. There is nothing about adding extra day after adding any months. Only short months are truncated to the last day of that month!!!

Again: try to apply common sense.

They mentioned about Leap year handled in these functions and you keep adding exceptions to that and calling it as Common Sense, Good Luck with that Common Sense..
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2019
Location: USA

PostPosted: Sat Nov 09, 2019 10:11 pm
Reply with quote

Rohit Umarjikar wrote:
sergeyken wrote:
Rohit Umarjikar wrote:
Your are free to try and convince yourself and create your own manual and discard what Syncsort has to say about their products.

I have carefully re-read the manual. There is nothing about adding extra day after adding any months. Only short months are truncated to the last day of that month!!!

Again: try to apply common sense.

They mentioned about Leap year handled in these functions and you keep adding exceptions to that and calling it as Common Sense, Good Luck with that Common Sense..

Please, read the manual carefully.
Good luck to you as well.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2019
Location: USA

PostPosted: Sun Nov 10, 2019 5:19 am
Reply with quote

BTW, according to both the utility manual, and common sense:
20190228 + 1month = 20190328, but not 20190331
20200228 + 1month = 20200328
20200229 + 1month = 20200329
20200430 + 1month = 20200530, but not 20200531
Etc. etc. etc.

It’s all absolutely clear, and logical.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies. View Bookmarks
All times are GMT + 6 Hours
Forum Index -> SYNCSORT

 


Similar Topics
Topic Forum Replies
No new posts Calling an Open C library function in... CICS 1
No new posts DATE2 function SYNCSORT 15
No new posts Help on PL/I jsonPutValue function PL/I & Assembler 8
No new posts how to use Tso outtrap external function All Other Mainframe Topics 8
No new posts INSYNC option with same function as I... JCL & VSAM 0
Search our Forums:

Back to Top