2012 Apr 26 11:32 AM
Need to develop a part of code that does compare 2 sums and allow a slight difference.
Now our code is:
IF NOT Invoice sum = Purchase order sum (exact amount)
EXIT.
We want to make both these sums to be + / - 5 in the sum of the amounts, to allow the differences in pennies.
What is the best way to go about it?
Help will be rewarded.
2012 Apr 26 11:38 AM
make a Range table...
Eg Invoice Sum = 100.. So Range table should have a value as
Low = 99.5 and High 100.5.
And then check PO sum is BETWEEN this range or not..
2012 Apr 26 11:38 AM
make a Range table...
Eg Invoice Sum = 100.. So Range table should have a value as
Low = 99.5 and High 100.5.
And then check PO sum is BETWEEN this range or not..
2012 Apr 26 1:00 PM
Is this the best way to go about it?
Also the invoice amount will offcourse wary from time to time.
And the low and high value will always be +5 or - 5.
So in other words it should be available to have the situation below:
Inv (Sum 95) = PO Inv (Sum 100) or
Inv(Sum 135) =PO Inv (Sum 130)
2012 Apr 26 1:15 PM
Take a varable X
Assign
X = Invoice Sum;
Again make Range Table
with lower limit as X - 0.5
And Upper Limit as X + 0.5
And check
IF NOT Invoice sum = Purchase order sum (exact amount)
Exit
2012 Apr 26 1:58 PM
Hi,
This is one way. It will show OK or NOT OK based on difference of 0.05. (you can change that value).
data : l_invoice type p decimals 2,
l_po type p decimals 2.
data : l_diff type p decimals 2.
*------------------ Values for testing
l_invoice = '100.78'.
l_po = '100.86'.
*----- Find difference
l_diff = l_invoice - l_po.
l_diff = abs( l_diff ).
write l_diff.
if l_diff <= '0.05'.
write 'OK'.
else.
write 'NOT OK'.
endif.
Regards,
Amit Mittal.
2012 Apr 26 2:37 PM