Focal Point Banner
Community Center Education Summit Technical Support User Groups
Let's Get Social!

Facebook Twitter LinkedIn YouTube
Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Packed Fields Causing Rounding Errors
Go
New
Search
Notify
Tools
Reply
  
[SOLVED] Packed Fields Causing Rounding Errors
 Login/Join
 
Platinum Member
posted
I use a couple of packed decimal fields formatted as P15.2 (VBR_PD_ELG_AMT) and P11.2 (VBR_GAIN_AMT) in the database in two DEFINE fields and define them as P15!d and P11!d because I want the whole dollar amount with the dollar sign. The code is below.

Most of the amounts are coming out fine. There are a few that are not rounding as they should. For example, 1852.12 comes out as $1853 oddly. There are only a few cases like this, but most of the amounts are rounding fine. Should I try to convert the packed decimal double precision fields in the database to something else before formatting them to a whole amount with the dollar sign..if anyone thinks?

  
DEFINE FILE pmr/pmr_prov_val_base_cluster
CLDR_DT/MDYY = DATECVT(ICURD_CLDR, 'I8YYMD', 'MDYY');
VBR_PD_ELG_AMT_P/P15!d = VBR_PD_ELG_AMT;
VBR_GAIN_AMT_P/P11!d = VBR_GAIN_AMT;
-*P_VBR_PD_ELG_AMT/P15!d = VBR_PD_ELG_AMT_P;
-*P_VBR_GAIN_AMT/P11!d = VBR_GAIN_AMT_P;
END

TABLE FILE pmr/pmr_prov_val_base_cluster
SUM VBR_PD_ELG_AMT
    PMR_PROV_VAL_BASE_CLUSTER.PROV_VAL_BASE_PMT_FCT.VBR_PD_ELG_AMT_P AS 'Potential'
	VBR_GAIN_AMT
    PMR_PROV_VAL_BASE_CLUSTER.PROV_VAL_BASE_PMT_FCT.VBR_GAIN_AMT_P AS 'Actual'
-*BY PMR_PROV_VAL_BASE_CLUSTER.PROV_VAL_BASE_PMT_FCT.ICURD_CLDR
BY CLDR_DT AS 'Month
WHERE VBR_PRCG_PCT_VAL NE 0;
WHERE SPEC_CD EQ 'AC' OR 'PD' OR 'OB';
WHERE PRIM_LCTN_SW EQ 'Y'
WHERE PMR_PROV_VAL_BASE_CLUSTER.PROV_DMN.PROV_NPI EQ &NPI;
END
-RUN
-EXIT

This message has been edited. Last edited by: AMC2,


WebFOCUS 8.2.06
SQL Server
HTML, PDF, Excel, etc
 
Posts: 160 | Registered: August 22, 2019Reply With QuoteReport This Post
Virtuoso
posted Hide Post
AMC2,

quote:
VBR_PD_ELG_AMT_P/P15!d = VBR_PD_ELG_AMT;


Try the following:
  
VBR_PD_ELG_AMT_P/P15!d = INT(VBR_PD_ELG_AMT + 0.5);


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

 
Posts: 1973 | Location: Tel Aviv, Israel | Registered: March 23, 2006Reply With QuoteReport This Post
Virtuoso
posted Hide Post
Since you reassign each single value from a DEFINE, each of them are rounded to then be added together by the SUM which may explain the "bad" rounding.
Try with the following where it is rounded and formatted only at display
TABLE FILE pmr/pmr_prov_val_base_cluster
SUM PMR_PROV_VAL_BASE_CLUSTER.PROV_VAL_BASE_PMT_FCT.VBR_PD_ELG_AMT_P/P15!d AS 'Potential'
    PMR_PROV_VAL_BASE_CLUSTER.PROV_VAL_BASE_PMT_FCT.VBR_GAIN_AMT_P/P15!d   AS 'Actual'
BY CLDR_DT AS 'Month
WHERE VBR_PRCG_PCT_VAL NE 0;
WHERE SPEC_CD EQ 'AC' OR 'PD' OR 'OB';
WHERE PRIM_LCTN_SW EQ 'Y'
WHERE PMR_PROV_VAL_BASE_CLUSTER.PROV_DMN.PROV_NPI EQ &NPI;
END
-RUN
-EXIT


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
 
Posts: 2370 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Reply With QuoteReport This Post
Platinum Member
posted Hide Post
Thanks MartinY - By the way, I just rounded and formatted at the display and that did take care of those few instances were the rounding was off. Thanks for your suggestion also Danny-SRL.


WebFOCUS 8.2.06
SQL Server
HTML, PDF, Excel, etc
 
Posts: 160 | Registered: August 22, 2019Reply With QuoteReport This Post
Virtuoso
posted Hide Post
AMC2,

According to the Forum Guidelines you should have marked you post as [SOLVED] and not [CLOSED]
Following these guidelines helps for further research


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
 
Posts: 2370 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Reply With QuoteReport This Post
Platinum Member
posted Hide Post
I did not mark it as [CLOSED]. Maybe the forum admin marked it as [CLOSED] maybe because I took a while to respond. I changed it to [SOLVED]. Thanks.


WebFOCUS 8.2.06
SQL Server
HTML, PDF, Excel, etc
 
Posts: 160 | Registered: August 22, 2019Reply With QuoteReport This Post
Virtuoso
posted Hide Post
Yes it was me as I didn't see any activity for 7 days and no acknowledgment that the last post from June 1st helped.


Thank you for using Focal Point!

Chuck Wolff - Focal Point Moderator
WebFOCUS 7x and 8x, Windows, Linux All output Formats
 
Posts: 2013 | Location: Customer Support | Registered: April 12, 2005Reply With QuoteReport This Post
  Powered by Social Strata  
 

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Packed Fields Causing Rounding Errors

Copyright © 1996-2018 Information Builders, leaders in enterprise business intelligence.