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 sum internal table column value with some common field value ?

former_member308418
Participant
0 Kudos

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

2 REPLIES 2

gouravkumar64
Active Contributor
0 Kudos

Hi,

Try with collect instead of APPEND.

Try this

Thanks

Gourav.

0 Kudos

Thanks Kumar.

Already tried with COLLECT but it does not give the accurate result.