Skip to Content
0
Former Member
Jul 16, 2008 at 06:15 PM

Using AT END OF two times in LOOP....

229 Views

Hello,

I have a following data in internal table ITAB:

BELNR-- -AMOUNT ----KUNNR

10001-- -100 --


3000

10001-- -200 --


3000

10002-- -300 --


3000

10002-- -400 --


3000

10003-- -50 --


4000

I want to print out like following:

10001-- 100 ---3000

10001-- 200 ---3000

Total Amount for document 10001 is 300

10002-- 300 ----3000

10002-- 400 ----3000

Total amount for document 10002 is 700.

______________________________________-

Total amount for customer 3000 is 1000.

_______________________________________

10003-- 50 --


4000

Total amount for document 10002 is 50

____________________________________

Total amount for customer 4000 is 50

____________________________________

I am using following logic but its not working. It still prints Total amount for customer at end of each document number but I want it print at end of customer.

Loop at ITAB:

V_DOC_AMOUNT = V_DOC_AMOUNT + ITAB-AMOUNT.

V_CUST_AMOUNT = V_CUST_AMOUNT + V_DOC_AMOUNT.

AT END OF BELNR.

write:/ 'Total amount for document is', v_DOC_amount.

CLEAR V_DOC_AMOUNT.

ENDAT.

AT END OF KUNNR.

WRITE:/ Total amount for customer is', v_cust_amount.

ENDAT.

ENDLOOP.

Regards,

Rajesh.AT