Skip to Content
author's profile photo Former Member
Former Member

Comparing two internal tables

Hi all,

I have one internal table itab1 which has contents from legacy system. Now I have another internal table itab2 which has contents from a SAP standard table,i.e. AMPL. I have to compare the contents of these two tables i.e. itab1 and itab2 and add those entries to the AMPL table which are present in itab1 but not in itab2. I can explain it more if anyone helps me out here. Points assured.

Thanks.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Jan 20, 2008 at 01:22 AM

    Hi SAP tech.. use this sample code..

    Sort table itab2 by k1 k2 k3..

    loop at itab1.

    read table itab2 with key k1 = itab1-k1

    k2 = itab1-k2 binary search.

    if sy-subrc = 0.

    delete itab2 index sy-index.

    endif.

    endloop.

    finally itab2 will have that sort of entries which are not in Itab1.

    Award points if helpful

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 20, 2008 at 03:31 AM

    Hi,

    For comparing 2 internal tables first we want to sort the two internal tables.

    But in some cases we dont know whether the two tables contain the same number of values(records).So we want to compare a single value to another int table.

    If there is any key value means we can check it with that by comparing tht particular value in loop.

    loop at itab.

    read table itab1 with key field values = itab-keyvalue. / We can also use loop at itab1 where keyvalue = itab-keyvalue.

    if sy-subrc = 0.

    if it matches we can do wht evr inside this block

    endif.

    endloop.

    reward if useful

    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.