Skip to Content

how to remove the Records from internal table based on another internal table

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Posted on Sep 08, 2016 at 11:10 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 08, 2016 at 12:24 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 08, 2016 at 02:40 PM

    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


    i1.jpg (116.1 kB)
    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.