This discussion is locked
2 Replies Latest reply: Oct 16, 2012 12:26 PM by ABAP 2 RSS

How to sum internal table column value with some common field value ?

ABAP 2
Currently Being Moderated

Dear all,

The above question is very similar to others questions, though I am facing some difficulty doing this. Please help me. My problem is,

 

In my internal table i'm selecting data from mseg table and based on bwart data in menge field will go on different columns like if bwart = '101' data will go to GRN column, if bwart = '303' data will go to TPN field. I have to add the values of GRNs if matnr , werks and budat are same.

 

 

Budat
Matnr
Menge1
Menge2
01.01.20122000001100


155
01.02.20122000002305
01.03.2012200000310010


1210

 

I need to have the following result:

 

 

Budat
Matnr
Menge1
Menge2
01.01.20122000001255
01.02.20122000002305
01.03.2012200000311220

 

Here I tried with At End Of matnr.

                        sum.

                         endat

But it not works as I am using conditional statement here.

Loop at itab into wa_it.
CASE WA_IT-BWART.
       WHEN '101' OR '305'.
         WA_FINAL-MENGEG = WA_IT-MENGE.
       WHEN '303'.
        WA_FINAL-MENGET = WA_IT-MENGE.
       WHEN '231' OR '251'.
         WA_FINAL-MENGES = WA_IT-MENGE.
       WHEN '551' OR 'Z01'.
         WA_FINAL-MENGEW = WA_IT-MENGE.
     ENDCASE.
     APPEND WA_FINAL TO IT_FINAL.
     CLEAR WA_FINAL.
   ENDLOOP.

 

   Please help.

 

Moderator message : Not enough re-search before posting, discussion locked

 

Message was edited by: Vinod Kumar

Actions