Skip to Content
0
Feb 07, 2011 at 09:52 AM

How to filter total greater than zero for every customer

54 Views

Hi to all,

Suppose a database table contain records for every customer for credit and debit amount and total field.

.

Customer1 credit debit

015 100 0

015 0 50

Total = - 50

Customer2 credit debit

16 0 200

16 50 0

16 0 0

Total = 150

Customer3 credit debit

10 10 10

10 0 0

Total = 10

Customer credit debit

21 5 0

Total = -5

I need to display total for every customer wise which are > 0.

Only positive total need to display, negative should not be display.

The code is written:

Data: l_v_customer type itab-customer_no.

l_v_total type itab-total.

Sort itab by customer_no.

l_v_total = 0.

Loop at itab into wa.

if sy-tabix = 1.

l_v_customer = wa-customer_no.

endif.

if l_v_customer = wa-customer_no.

l_v_total = l_v_total + wa-total.

else.

if l_v_total LT '0'.

Delete itab where custome_no = l_v_customer.

endif.

l_v_customer = wa-customer_no.

l_v_total = wa-total.

endif.

endloop.

This code is not giving correct result.

Please can any one suggest me correct code to display total > 0 for every customer.

I shall be thankful to you for this .

Regards

Pavneet Rana

Edited by: pavneet rana on Feb 7, 2011 2:59 PM