Rounding
Terry A. Pickering
pickering@myself.com
Fri, 29 Oct 1999 06:25:52 -0700
Does anyone have ideas on how to force an amount that has been split over
multiple records, to total EXACTLY to the original amount? Rounding doesn't
appear to solve the problem.
The situation is when you start with an amount, then distribute it based on
a percentage. I want the sum total of the distribution to match.
For example if I want to distribute $100.00 out to three records, It would
need to be:
Record 1: $33.33
Record 2: $33.33
Record 3: $33.34
The numbers are stored as integers with implied decimal places.
The actual application is that I have amounts in receiving records that are
already distributed. Now I need to calculate a remaining amount not
received - and distribute that based on the original distribution percentage.
ACCESS PO-DTL LINK TO PO-DISTRIB
SORT ON PO-LINE
DEFINE AMT-REMAIN INT*8 = AMT-ORDER - AMT-RCVD
DEFINE DISTRIB-PCT = AMT-DISTRIB / AMT-ORDER
DEFINE AMT-REMAIN-DISTRIB INT*10 = AMT-REMAIN * DISTRIB-PCT
PO-DTL
------
PO-LINE AMT-ORDER AMT-RCVD
------- --------- --------
A1 $56.93 $53.90
PO-DISTRIB
----------
PO-LINE AMT-DISTRIB
------- -----------
A1 $28.46
A1 $28.47
The results I get are:
AMT-REMAIN = $3.03
AMT-REMAIN-DISTRIB (Record 1) = $1.51
AMT-REMAIN-DISTRIB (Record 2) = $1.51
I've tried different ways of rounding, and sometimes it fixes it, sometimes
it doesn't. What I ideally would like, is a way that when the sort break
occurs, it would add a "fudge factor" to the last record to make sure they
all total up correctly. This needs to be done in QTP.
Any suggestions?????
Terry Pickering CompuGroup, Inc.
pickering@myself.com Portland, Oregon USA
www.teleport.com/~compugrp Cessna 172 & Lancair ES
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Subscribe: "subscribe powerh-l" in message body to majordomo@lists.swau.edu
Unsubscribe: "unsubscribe powerh-l" in message to majordomo@lists.swau.edu
This list is closed, thus to post to the list, you must be a subscriber.