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: 

How to calculate the values

Former Member
0 Kudos

Hi Experts,

I have doubt, i have an internal table now i want to calculate the total for every group. How to do that?

value type

-


5,439.01 ; ZMP0

509.60 ; ZMP0

4,749.26 ; ZMP0

9,053.95- ZPNL

732.70- ZPNL

66.30- ZPNL

18.10- ZS03

63.90 ; ZS03

According to the type i need a total for ZMPO, ZPNL, ZSO3 separately.

how to do that?

5,439.01 ; ZMP0

509.60 ; ZMP0

4,749.26 ; ZMP0

ZMPO total =

9,053.95- ZPNL

732.70- ZPNL

66.30- ZPNL

ZPNL total =

18.10- ZS03

63.90 ; ZS03

ZSO3 total =

Like that i need, can any one help this?

Regards,

Mohana

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hello,

Use the COLLECT.


DATA:
  wa LIKE LINE OF itab,
  itab_sum LIKE itab.

SORT itab BY key.

LOOP AT itab INTO wa.
  COLLECT wa INTO itab_sum.
ENDLOOP.

The itab_sum has the same structure like the itab where is the data to me summarized, and the wa has the line structure of the itab.

Regards.

2 REPLIES 2

Former Member
0 Kudos

Hello,

Use the COLLECT.


DATA:
  wa LIKE LINE OF itab,
  itab_sum LIKE itab.

SORT itab BY key.

LOOP AT itab INTO wa.
  COLLECT wa INTO itab_sum.
ENDLOOP.

The itab_sum has the same structure like the itab where is the data to me summarized, and the wa has the line structure of the itab.

Regards.

Former Member
0 Kudos

use the command COLLECT

declare a interna table aux. with same estructure of the other

sort the table by the field with text

data: i_t_aux like i_t occurs 0 with header line.

loop at i_t.

colllect i_t into i_t_aux.

endloop.