Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Compare 2 sums for invoices

0 Kudos
132

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.

1 ACCEPTED SOLUTION

former_member209818
Active Contributor
0 Kudos
83

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..

5 REPLIES 5

former_member209818
Active Contributor
0 Kudos
84

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..

0 Kudos
83

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)

0 Kudos
83

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


Former Member
0 Kudos
83


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.

Former Member
0 Kudos
83

Basic

Locked.

Rob