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 remove the Records from internal table based on another internal table

venkatasap
Participant
0 Kudos
495

Hi Sap All.

I have got a requirement where iam selecting all materials from table MARA into Internal table itab.

after I fetch the data into Internal table itab from MARA, I have to do the check if those materials in tab has a 0 stock in table MBEW.

based on the field MBEW-LBKUM. if it is value '0' then I have to remove the respective material from itab.

can any one help me in finding the code for the above.

Regards.

Jagdish.

3 REPLIES 3

raymond_giuseppi
Active Contributor
0 Kudos
181

For performance don't use internal tables but a single SELECT with either JOIN between MARA and MBEW or (better IMHO) a subquery on MBEW to check for some not initial quantity.

Regards,

Raymond

krishnaananth
Active Participant
0 Kudos
181

Why dont you start from MBEW

select matnr from MBEW into ____ where LBKUM <> 0

Use collect statement if required to add stock..

Then you can fetch material data from MARA...

I think this is easy way...

Regards,

Ananth

former_member185116
Active Participant
0 Kudos
181

Hi,

you can use internal table, but performance wise an inner join would be better,

try below code,

TABLES : mara, mbew.
 

data : BEGIN OF wa_itab,
        matnr type mara-matnr,
        bwkey type mbew-bwkey,
        lbkum type mbew-lbkum,
        END OF wa_itab.

data : it_itab like TABLE OF wa_itab.


START-OF-SELECTION.


    select a~matnr
           b~bwkey
           b~lbkum
           from mara as a
           INNER JOIN mbew as b
           on a~matnr eq b~matnr
           into CORRESPONDING FIELDS OF TABLE it_itab
           WHERE b~lbkum ne '0'
           ORDER BY a~matnr.



     loop at it_itab into wa_itab.

     endloop.

see the output