cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Calculating total amount/sum from internal tables

Former Member
0 Likes
963

Hello guys

I am trying to calculate the total amount/sum of prices of my internal table using subroutines. I only get a table with the prices, but not the prices added up together.

This is what I have so far:

REPORT y_sum.
DATA: it_sum TYPE TABLE OF yreservation,
wa_sum LIKE LINE OF it_sum,
price TYPE yreservation-price,
sum TYPE i.

SELECT *
FROM yreservation
INTO CORRESPONDING FIELDS OF TABLE it_sum
UP TO 500 ROWS.

SKIP 1.
SORT it_sum BY price.
WRITE:/ 'Price', 15 'Gross Payment'.
WRITE:/ sy-uline(70).

PERFORM total USING wa_sum-price CHANGING sum.
FORM total
USING total_price TYPE any
CHANGING total_sum TYPE any.
total_sum = total_sum + total_price.

LOOP AT it_sum INTO wa_sum.
WRITE: / wa_sum-price UNDER 'Price',
sum UNDER 'Gross payment'.

ENDLOOP.
ENDFORM.

I hope you guys can help 🙂

Accepted Solutions (0)

Answers (0)