Former Member

# Compare 2 sums for invoices

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.

##### Add a comment
10|10000 characters needed characters exceeded

### Related questions

Posted on Apr 26, 2012 at 10: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..

##### Add a comment
10|10000 characters needed characters exceeded
• Former Member Former Member

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
Posted on Apr 26, 2012 at 12: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.

##### Add a comment
10|10000 characters needed characters exceeded
• Former Member
Posted on Apr 26, 2012 at 01:37 PM

Basic

Locked.

Rob

##### Add a comment
10|10000 characters needed characters exceeded