<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: comparing two internal tables in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-two-internal-tables/m-p/5311712#M1224619</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use something like:-&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
sort itab1 by field1 field2 field3.
sort itab2 by field1 field2 field3.

loop at itab1.
  read table itab2 with key field1 = itab1-field1
                            field2 = itab1-field2
                            field3 = itab1-field3.
  if sy-subrc = 0.
    delete itab1.
  endif.
  clear itab1.
endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Tarun&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 04 Mar 2009 04:18:16 GMT</pubDate>
    <dc:creator>I355602</dc:creator>
    <dc:date>2009-03-04T04:18:16Z</dc:date>
    <item>
      <title>comparing two internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-two-internal-tables/m-p/5311711#M1224618</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i have to compare  two internal  tables  based on  3 fields and if the  lineitems with those fields are matching , i have to delete that line item from the first internal table.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Mar 2009 04:15:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-two-internal-tables/m-p/5311711#M1224618</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-04T04:15:06Z</dc:date>
    </item>
    <item>
      <title>Re: comparing two internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-two-internal-tables/m-p/5311712#M1224619</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use something like:-&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
sort itab1 by field1 field2 field3.
sort itab2 by field1 field2 field3.

loop at itab1.
  read table itab2 with key field1 = itab1-field1
                            field2 = itab1-field2
                            field3 = itab1-field3.
  if sy-subrc = 0.
    delete itab1.
  endif.
  clear itab1.
endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Tarun&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Mar 2009 04:18:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-two-internal-tables/m-p/5311712#M1224619</guid>
      <dc:creator>I355602</dc:creator>
      <dc:date>2009-03-04T04:18:16Z</dc:date>
    </item>
    <item>
      <title>Re: comparing two internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-two-internal-tables/m-p/5311713#M1224620</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try like this....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

loop at itab into w_itab.                                                                
    delete itab2 where &amp;lt;field name&amp;gt; eq w_itab-&amp;lt;fieldname&amp;gt;.                                   
  endloop.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Hope its helps&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Mar 2009 04:26:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-two-internal-tables/m-p/5311713#M1224620</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-04T04:26:23Z</dc:date>
    </item>
    <item>
      <title>Re: comparing two internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-two-internal-tables/m-p/5311714#M1224621</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is the combination of the three fields unique  ?&lt;/P&gt;&lt;P&gt;If its is ,  use read else use loop to check condition&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Mar 2009 04:28:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-two-internal-tables/m-p/5311714#M1224621</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-04T04:28:13Z</dc:date>
    </item>
    <item>
      <title>Re: comparing two internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-two-internal-tables/m-p/5311715#M1224622</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Firstly create tmp table of type itab1 or u can also create table with only  columns which are common in both tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * into tmp from itab1 inner join itab2 where itab1-field1 = itab2-field1 and itab1-field2 = itab2-field2 and itab1-field3 = itab2-field3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at tmp.&lt;/P&gt;&lt;P&gt;  delete from itab1 where itab1-field1 = tmp-field1 and itab1-field2 = tmp-field2&lt;/P&gt;&lt;P&gt;  and itab1-field3 = tmp-field3.  &lt;/P&gt;&lt;P&gt;  endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Smita&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Mar 2009 04:29:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-two-internal-tables/m-p/5311715#M1224622</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-04T04:29:02Z</dc:date>
    </item>
    <item>
      <title>Re: comparing two internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-two-internal-tables/m-p/5311716#M1224623</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Dude,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
sort table1 by field1 field2 field3.
sort table2 by field1 field2 field3.
 
loop at table1 into wa_table1.
  read table table2 into wa_table2 with key field1 = wa_table1-field1
                            field2 = wa_table1-field2
                            field3 = wa_table1-field3.
  if sy-subrc = 0.
    delete table table1 from wa_table1.
  endif.
  clear table1.
endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Mar 2009 04:29:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-two-internal-tables/m-p/5311716#M1224623</guid>
      <dc:creator>former_member632729</dc:creator>
      <dc:date>2009-03-04T04:29:17Z</dc:date>
    </item>
    <item>
      <title>Re: comparing two internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-two-internal-tables/m-p/5311717#M1224624</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi use something below to sort the two internal tables after tables having all data .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sort table1 by field1 field2 field3."sorting two internal tables&lt;/P&gt;&lt;P&gt;sort table2 by field1 field2 field3.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at table1 into wa_table1."Comparing record by record whether they are equal.&lt;/P&gt;&lt;P&gt;  read table table2 into wa_table2 with key field1 = wa_table1-field1&lt;/P&gt;&lt;P&gt;                            field2 = wa_table1-field2&lt;/P&gt;&lt;P&gt;                            field3 = wa_table1-field3.&lt;/P&gt;&lt;P&gt;  if sy-subrc = 0." if yes delete &lt;/P&gt;&lt;P&gt;    delete table table1 from wa_table1.&lt;/P&gt;&lt;P&gt;  endif.&lt;/P&gt;&lt;P&gt;  clear table1.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Mar 2009 07:14:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-two-internal-tables/m-p/5311717#M1224624</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-04T07:14:47Z</dc:date>
    </item>
    <item>
      <title>Re: comparing two internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-two-internal-tables/m-p/5311718#M1224625</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

sort int_table1 by field1 field2 field3.
sort int_table2 by field1 field2 field3.

loop at int_table1 into wa_table1.

 delete int_table2 where field1 = wa_table1-field1  OR field2 = wa_table1-field2  OR field3 = wa_table1-field3.

endloop.


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ritesh J&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Mar 2009 07:26:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-two-internal-tables/m-p/5311718#M1224625</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-04T07:26:04Z</dc:date>
    </item>
    <item>
      <title>Re: comparing two internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-two-internal-tables/m-p/5311719#M1224626</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;loop at itab.&lt;/P&gt;&lt;P&gt;  read table itab1 with key fieldname1 = itab-fieldname1&lt;/P&gt;&lt;P&gt;                            fieldname2 = itab-fieldname2.&lt;/P&gt;&lt;P&gt; if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;    delete itab.&lt;/P&gt;&lt;P&gt;  endif.&lt;/P&gt;&lt;P&gt; endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Joan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Mar 2009 07:40:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-two-internal-tables/m-p/5311719#M1224626</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-04T07:40:21Z</dc:date>
    </item>
    <item>
      <title>Re: comparing two internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-two-internal-tables/m-p/5311720#M1224627</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Santosh,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can do like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

Suppose you have two internal tables itab1 and itab2 having common field filed1 between them then,

Loop at itab1 into wa1 .

Read table itab2 into wa2 with key field1 = wa1-field1.

if sy-subrc = 0.       "this will give 0 if there is any common data between the two internal tables data

delete itab1 from wa1.

endif.

endloop.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regrds&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mansi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: MANSI  ASNANI on Mar 4, 2009 8:44 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Mar 2009 07:44:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-two-internal-tables/m-p/5311720#M1224627</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-04T07:44:31Z</dc:date>
    </item>
    <item>
      <title>Re: comparing two internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-two-internal-tables/m-p/5311721#M1224628</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Santosh.&lt;/P&gt;&lt;P&gt;        The following code is working and will meet ur purpose.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TYPES: BEGIN OF T_ITAB1,&lt;/P&gt;&lt;P&gt;       FLD1(5) TYPE C,&lt;/P&gt;&lt;P&gt;       FLD2(5) TYPE C,&lt;/P&gt;&lt;P&gt;       FLD3(5) TYPE C,&lt;/P&gt;&lt;P&gt;       END OF T_ITAB1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TYPES: BEGIN OF T_ITAB2,&lt;/P&gt;&lt;P&gt;       FLD1(5) TYPE C,&lt;/P&gt;&lt;P&gt;       FLD2(5) TYPE C,&lt;/P&gt;&lt;P&gt;       FLD3(5) TYPE C,&lt;/P&gt;&lt;P&gt;       END OF T_ITAB2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; DATA: ITAB1 TYPE STANDARD TABLE OF T_ITAB1,&lt;/P&gt;&lt;P&gt;       ITAB2 TYPE STANDARD TABLE OF T_ITAB2,&lt;/P&gt;&lt;P&gt;       WA_ITAB1 LIKE LINE OF ITAB1,&lt;/P&gt;&lt;P&gt;       WA_ITAB2 LIKE LINE OF ITAB2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   WA_ITAB1-FLD1 = 'AAAA'.&lt;/P&gt;&lt;P&gt;   WA_ITAB1-FLD2 = '1111'.&lt;/P&gt;&lt;P&gt;   WA_ITAB1-FLD3 = '2222'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   APPEND WA_ITAB1 TO ITAB1.&lt;/P&gt;&lt;P&gt;   CLEAR WA_ITAB1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   WA_ITAB1-FLD1 = 'BBBB'.&lt;/P&gt;&lt;P&gt;   WA_ITAB1-FLD2 = '6666'.&lt;/P&gt;&lt;P&gt;   WA_ITAB1-FLD3 = '7777'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   APPEND WA_ITAB1 TO ITAB1.&lt;/P&gt;&lt;P&gt;   CLEAR WA_ITAB1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  *********************************&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   WA_ITAB2-FLD1 = 'AAAA'.&lt;/P&gt;&lt;P&gt;   WA_ITAB2-FLD2 = '1111'.&lt;/P&gt;&lt;P&gt;   WA_ITAB2-FLD3 = '2222'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   APPEND WA_ITAB2 TO ITAB2.&lt;/P&gt;&lt;P&gt;   CLEAR WA_ITAB2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   WA_ITAB2-FLD1 = 'CCCC'.&lt;/P&gt;&lt;P&gt;   WA_ITAB2-FLD2 = '8888'.&lt;/P&gt;&lt;P&gt;   WA_ITAB2-FLD3 = '9999'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   APPEND WA_ITAB2 TO ITAB2.&lt;/P&gt;&lt;P&gt;   CLEAR WA_ITAB2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*************************************&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT ITAB1 INTO WA_ITAB1.&lt;/P&gt;&lt;P&gt;  LOOP AT ITAB2 INTO WA_ITAB2.&lt;/P&gt;&lt;P&gt;     IF WA_ITAB2-FLD1 = WA_ITAB1-FLD1 AND WA_ITAB2-FLD2 = WA_ITAB1-FLD2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        DELETE ITAB1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;     ENDIF.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks and Regards&lt;/P&gt;&lt;P&gt;Suraj S Nair&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Mar 2009 09:37:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-two-internal-tables/m-p/5311721#M1224628</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-04T09:37:31Z</dc:date>
    </item>
  </channel>
</rss>

