Skip to Content
0
Former Member
Feb 17, 2011 at 11:19 PM

Issue With Dynamic Internal Table Calculations

29 Views

Hi All,

I have a dynamic internal Table and i want to calculate the sum of QTY if MAT is same

Say ITAB is my dynamic internal table With below entries

MAT             QTY

    A            1
    A            2
    A            3
    B            4
    B            5
    C            6

I want my dynamic internal table to look like

A    6
B    9
C    6

1) I tried below code

LOOP AT <itab> INTO <WA>.
  assign <WA> TO <WA_TEMP>.
    assign component 'MAT' of structure <wa> to <fs>.

  at end of <fs>.
   SUM.  *" SUM Not allowed with in loop assigning*
   ENDAT.
ENDLOOP.

Would appreciate if anyone can comment on the issue

Thanks in advance