Portal | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
swathykrishnan

New User

Joined: 01 Oct 2010
Posts: 43
Location: Bangalore

 Posted: Mon Sep 12, 2011 10:33 am    Post subject: ONCODE 310 FIXED DECIMAL OVERFLOW Hi I have 3 variables with the definition given below A FIXED BIN(15,2) B FIXED BIN(15,2) C FIXED BIN(5,2) And the the following operation will be performed on these variables A=ROUND((B * (ROUND(PREC(C/100.5,4),3)),2) This code will give ONCODE 310 when B is having 13 digits in integer part. It will work fine till B is having 12 digits in integer part. We can use MULTIPLY function to avoid this issue. But it will cause truncation of decimal fields. Is there any other way to fix this issue?

Bill Woodger

Moderator Emeritus

Joined: 09 Mar 2011
Posts: 7312
Location: Inside the Matrix

 Posted: Mon Sep 12, 2011 11:50 am    Post subject: Re: ONCODE 310 FIXED DECIMAL OVERFLOW I don't think you have fully described your problem. If the sub-calculation of C, for instance, returns a value of 1, are you saying you'd get an error with B having 13 digits before the decimal place?
swathykrishnan

New User

Joined: 01 Oct 2010
Posts: 43
Location: Bangalore

 Posted: Mon Sep 12, 2011 12:17 pm    Post subject: Hi Bill The value of C will be always always <=100. If its sub calculation gives 1 it wont create any issues. Say value of C as 12.55 and B=9874567654321.88 the program will abend with ONCODE 310.
Bill Woodger

Moderator Emeritus

Joined: 09 Mar 2011
Posts: 7312
Location: Inside the Matrix

 Posted: Mon Sep 12, 2011 12:33 pm    Post subject: Reply to: ONCODE 310 FIXED DECIMAL OVERFLOW So, if you, in your data definition, have a maximum of 13 positions before the decimal place, and you have a 13 non-decimal-digit number, and you multiply by 10, you get 14 digits, which don't fit, so POP. You definition should be made big enough to contain the maximum value that is reasonable for the program to handle.
prino

Senior Member

Joined: 07 Feb 2009
Posts: 1220
Location: Vilnius, Lithuania

 Posted: Mon Sep 12, 2011 8:31 pm    Post subject: You do not, EVER, use "fixed bin (15,2)" variables in PL/I. If you want to use fractions in PL/I you use FIXED DEC! Given the numbers you post, 9874567654321.88 and 12.55, you also don't have a clue as to what a "fixed bin (15,2)" actually means, as neither of them can ever be stored into a variable of that type and precision.
dbzTHEdinosauer

Global Moderator

Joined: 20 Oct 2006
Posts: 6970
Location: porcelain throne

 Posted: Mon Sep 12, 2011 9:36 pm    Post subject: you don't do it with cobol either. lot of knuckleheads think binary computations are faster, (even though z/os has hardware / middleware / decimal functions) and all the bytes you can save with binary fields. a lot of misconceptions and little understanding lead to problems like the ts has posted. did the rastelle thumb a few years ago. did not know that it was you.
Akatsukami

Global Moderator

Joined: 03 Oct 2009
Posts: 1789
Location: Bloomington, IL

Posted: Mon Sep 12, 2011 9:55 pm    Post subject:

 dbzTHEdinosauer wrote: lot of knuckleheads think binary computations are faster, (even though z/os has hardware / middleware / decimal functions)

z/OS??? System/360 had microcoded decimal instructions in 1964.

These toy software engineers with experience limited to toy computers need to grow up before they try programming in the real world
swathykrishnan

New User

Joined: 01 Oct 2010
Posts: 43
Location: Bangalore

Posted: Tue Sep 13, 2011 11:44 am    Post subject: Reply to: ONCODE 310 FIXED DECIMAL OVERFLOW

Hi Prino.

That was a mistake from my side.. I am using FIXED DEC only...

 Code: A FIXED DEC(15,2) B FIXED DEC(15,2) C FIXED DEC(5,2)

In the example we can see B is having 13 digits integer and 2 digits decimal. And subcalculation of C will have 3 decimal part. So the result of multiplication will have 18 digits. At that time only the program will end with 310.
FLOAT DECIMAL will fix this issue. But ROUND is not working on FLOAT DEC. And if we move it to FIXED DEC it will take 15 digits from left and last 3 digits of decimal part will get truncated.
Bill Woodger

Moderator Emeritus

Joined: 09 Mar 2011
Posts: 7312
Location: Inside the Matrix

 Posted: Tue Sep 13, 2011 12:37 pm    Post subject: Reply to: ONCODE 310 FIXED DECIMAL OVERFLOW Presumably PL/I has an equivalent to Cobol's ARITH(31) compiler option, if your problem is a plain lack of digits. Unrelated, but with A being such a vast number, are you really sure your user is worried about +/- .01 from the final rounding? It is unusual to me to see the rounding of the intermediate products. If that is what the user wants, OK.
prino

Senior Member

Joined: 07 Feb 2009
Posts: 1220
Location: Vilnius, Lithuania

Posted: Tue Sep 13, 2011 1:20 pm    Post subject: Re: Reply to: ONCODE 310 FIXED DECIMAL OVERFLOW

 Bill Woodger wrote: Presumably PL/I has an equivalent to Cobol's ARITH(31) compiler option, if your problem is a plain lack of digits.

 Code: *process limits(fixeddec(15,31) fixedbin(31,63));

And don't be a smart-ass, and use

 Code: *process limits(fixeddec(31,31) fixedbin(63,63));
swathykrishnan

New User

Joined: 01 Oct 2010
Posts: 43
Location: Bangalore

 Posted: Tue Sep 13, 2011 3:11 pm    Post subject: Hi Bill Yes the user need it to get rounded for 2 digits even if its a vast number... MULTIPLY or FLOAT DECIMAL will fix this issue... But we need to ROUND it...
Bill Woodger

Moderator Emeritus

Joined: 09 Mar 2011
Posts: 7312
Location: Inside the Matrix

 Posted: Tue Sep 13, 2011 3:22 pm    Post subject: Hi, Did you see Prino's last post? If you need more digits than you are "allowed", use the compiler option he has posted to give yourself access to more digits. Then you can define your fields as big enough for your purposes, and ROUND it to your heart's content.
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics To convert numeric to Packed Decimal vinu78 DFSORT/ICETOOL 9 Fri Jul 31, 2020 7:14 pm comparasion between BIN FIXED(63) an... javen777 PL/I & Assembler 10 Wed Apr 22, 2020 5:11 pm Convert a packed decimal value to zon... Dinesh Mani DB2 6 Mon Mar 16, 2020 6:02 pm Variable length(Pipe delimter) to Fix... SreekanthMada DFSORT/ICETOOL 8 Mon Jan 06, 2020 4:44 pm Identifying Packed Decimal data in a ... sojivarkey TSO/ISPF 4 Sat Dec 07, 2019 5:36 am

 © 2003-2020 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us