<?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: Compare two internal tables in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/compare-two-internal-tables/m-p/8400786#M1644739</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you can achieve this before loading the internal table ITAB1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just in the Select Statement for ITAB1 use for all entries.&lt;/P&gt;&lt;P&gt;ex:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT * FROM &amp;lt;TABLE&amp;gt;
INTO CORRESPONDING FIELDS OF TABLE ITAB1
FOR ALL ENTRIES IN ITAB
WHERE       MATKL = ITAB1-MATKL.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 15 Dec 2011 04:27:37 GMT</pubDate>
    <dc:creator>surajarafath</dc:creator>
    <dc:date>2011-12-15T04:27:37Z</dc:date>
    <item>
      <title>Compare two internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/compare-two-internal-tables/m-p/8400785#M1644738</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;I have two internal tables ITAB and ITAB1. I have to compare the two tables based on a Field 'MATKL'.&lt;/P&gt;&lt;P&gt;That is, ITAB contains a list of MATKL, and ITAB1 has MATKL and their corresponding MATNR's.&lt;/P&gt;&lt;P&gt;I have to keep only those records in ITAB1, which have a corresponding record in ITAB.&lt;/P&gt;&lt;P&gt;Please suggest.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Dec 2011 04:21:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/compare-two-internal-tables/m-p/8400785#M1644738</guid>
      <dc:creator>chetan_mishra</dc:creator>
      <dc:date>2011-12-15T04:21:42Z</dc:date>
    </item>
    <item>
      <title>Re: Compare two internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/compare-two-internal-tables/m-p/8400786#M1644739</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you can achieve this before loading the internal table ITAB1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just in the Select Statement for ITAB1 use for all entries.&lt;/P&gt;&lt;P&gt;ex:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT * FROM &amp;lt;TABLE&amp;gt;
INTO CORRESPONDING FIELDS OF TABLE ITAB1
FOR ALL ENTRIES IN ITAB
WHERE       MATKL = ITAB1-MATKL.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Dec 2011 04:27:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/compare-two-internal-tables/m-p/8400786#M1644739</guid>
      <dc:creator>surajarafath</dc:creator>
      <dc:date>2011-12-15T04:27:37Z</dc:date>
    </item>
    <item>
      <title>Re: Compare two internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/compare-two-internal-tables/m-p/8400787#M1644740</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;Your post i dint get ,can you elaborate clearly you want to fetch from single table and placed that same value in other table. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to place common matnr in internal table use for all entries in the second query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&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;G.Aditya&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Aditya.G on Dec 15, 2011 10:18 AM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Aditya.G on Dec 15, 2011 10:21 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Dec 2011 04:43:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/compare-two-internal-tables/m-p/8400787#M1644740</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-12-15T04:43:46Z</dc:date>
    </item>
    <item>
      <title>Re: Compare two internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/compare-two-internal-tables/m-p/8400788#M1644741</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;&lt;/P&gt;&lt;P&gt;SELECT * FROM ITAB&lt;/P&gt;&lt;P&gt;INTO CORRESPONDING FIELDS OF ITAB1&lt;/P&gt;&lt;P&gt;WHERE MATKL = ITAB1-MATKL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Warm Regards,&lt;/P&gt;&lt;P&gt;PavanKumar.G&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: pavankumar.g on Dec 15, 2011 5:45 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Dec 2011 04:44:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/compare-two-internal-tables/m-p/8400788#M1644741</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-12-15T04:44:56Z</dc:date>
    </item>
    <item>
      <title>Re: Compare two internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/compare-two-internal-tables/m-p/8400789#M1644742</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Pavan, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried this but I get an error  " 'ITAB' is not defined in the ABAP dictionary as a table, projection view, or  database view."&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Dec 2011 04:53:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/compare-two-internal-tables/m-p/8400789#M1644742</guid>
      <dc:creator>chetan_mishra</dc:creator>
      <dc:date>2011-12-15T04:53:04Z</dc:date>
    </item>
    <item>
      <title>Re: Compare two internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/compare-two-internal-tables/m-p/8400790#M1644743</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 the following code .. &lt;/P&gt;&lt;P&gt;first create an internal table with required fields.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;for eg: 

data:begin of it_final occurs 0,
          matnr type matnr,
          maktl  type maktl,
        end of it_final.

Loop at itab.
read table itab1 into wa with key where matnr = itab-matnr.
move wa-matnr to it_final-matnr.
move wa-maktl  to it_final-maktl.

append it_final.
clear it_final.

endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now you have required fields into your internal table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: naresh bammidi on Dec 15, 2011 5:58 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Dec 2011 04:57:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/compare-two-internal-tables/m-p/8400790#M1644743</guid>
      <dc:creator>naresh_bammidi</dc:creator>
      <dc:date>2011-12-15T04:57:02Z</dc:date>
    </item>
    <item>
      <title>Re: Compare two internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/compare-two-internal-tables/m-p/8400791#M1644744</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;select * from mara into corresponding fields of table itab .                &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if itab is not initial.&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;  select * from mara into corresponding fields of table itab1 for all entries in itab where maktl = itab-maktl.   &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Dec 2011 05:00:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/compare-two-internal-tables/m-p/8400791#M1644744</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-12-15T05:00:35Z</dc:date>
    </item>
    <item>
      <title>Re: Compare two internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/compare-two-internal-tables/m-p/8400792#M1644745</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Bach,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try this one &lt;/P&gt;&lt;P&gt;SELECT * FROM MARA&lt;/P&gt;&lt;P&gt;INTO CORRESPONDING FIELDS OF TABLE ITAB1&lt;/P&gt;&lt;P&gt;FOR ALL ENTRIES IN ITAB&lt;/P&gt;&lt;P&gt;WHERE MATKL = ITAB1-MATkL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Warm Regards,&lt;/P&gt;&lt;P&gt;PavanKumar.G&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: pavankumar.g on Dec 15, 2011 6:01 AM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: pavankumar.g on Dec 15, 2011 6:11 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Dec 2011 05:00:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/compare-two-internal-tables/m-p/8400792#M1644745</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-12-15T05:00:40Z</dc:date>
    </item>
    <item>
      <title>Re: Compare two internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/compare-two-internal-tables/m-p/8400793#M1644746</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Aditya,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My query is : &lt;/P&gt;&lt;P&gt;I have a table ITAB populated through various select logics, it contains the  field 'MATNR''.&lt;/P&gt;&lt;P&gt;There's another table ITAB1, which fetches data (MATNR) from MARA for specific 'MATKL' (picked  from another table).&lt;/P&gt;&lt;P&gt;I have to keep only those records in ITAB, for which there is a corresponding record in the table ITAB1, and delete the others.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Dec 2011 05:06:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/compare-two-internal-tables/m-p/8400793#M1644746</guid>
      <dc:creator>chetan_mishra</dc:creator>
      <dc:date>2011-12-15T05:06:21Z</dc:date>
    </item>
    <item>
      <title>Re: Compare two internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/compare-two-internal-tables/m-p/8400794#M1644747</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;select statement won,t work for internal tables,it's only to fetch the data from data base table.that is the reason it is showing error.use DB table instead of internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Naresh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Dec 2011 05:07:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/compare-two-internal-tables/m-p/8400794#M1644747</guid>
      <dc:creator>naresh_bammidi</dc:creator>
      <dc:date>2011-12-15T05:07:01Z</dc:date>
    </item>
    <item>
      <title>Re: Compare two internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/compare-two-internal-tables/m-p/8400795#M1644748</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;&lt;/P&gt;&lt;P&gt;From which table you retrieve the data for the first query.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Dec 2011 05:13:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/compare-two-internal-tables/m-p/8400795#M1644748</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-12-15T05:13:01Z</dc:date>
    </item>
    <item>
      <title>Re: Compare two internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/compare-two-internal-tables/m-p/8400796#M1644749</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Then You try like this,&lt;/P&gt;&lt;P&gt;with this logic you delete the entries which doesnt have in ITAB&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT ITAB1 INTO WA_ITAB1.
READ TABLE ITAB WITH KEY MATKL = WA_ITAB1-MATKL TRANSPORTING NO FIELDS.
IF SY-SUBRC NE 0.
DELETE ITAB1 INDEX SY-TABIX.
ENDIF.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Dec 2011 05:23:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/compare-two-internal-tables/m-p/8400796#M1644749</guid>
      <dc:creator>surajarafath</dc:creator>
      <dc:date>2011-12-15T05:23:41Z</dc:date>
    </item>
    <item>
      <title>Re: Compare two internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/compare-two-internal-tables/m-p/8400797#M1644750</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ravi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The first Internal Table is fetched from multiple tables, and some fields are calculated and then appended.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Dec 2011 05:25:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/compare-two-internal-tables/m-p/8400797#M1644750</guid>
      <dc:creator>chetan_mishra</dc:creator>
      <dc:date>2011-12-15T05:25:26Z</dc:date>
    </item>
    <item>
      <title>Re: Compare two internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/compare-two-internal-tables/m-p/8400798#M1644751</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Bachack,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//  use this query&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from mara into corresponding fields of table itab1 for all entries in itab where matnr = itab-matnr. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// This query retrieves the data for the revelant matnr in itab .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Dec 2011 05:34:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/compare-two-internal-tables/m-p/8400798#M1644751</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-12-15T05:34:39Z</dc:date>
    </item>
    <item>
      <title>Re: Compare two internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/compare-two-internal-tables/m-p/8400799#M1644752</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 below logic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Data : LW_TABIX TYPE SYTABIX.

LOOP AT ITAB1 INTO WA_ITAB1.
CLEAR LW_TABIX.
LW_TABIX = SY-TABIX.
READ TABLE ITAB WITH KEY MATKL = WA_ITAB1-MATKL TRANSPORTING NO FIELDS.
IF SY-SUBRC NE 0.
DELETE ITAB1 INDEX LW_TABIX.
ENDIF.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Vijay&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Dec 2011 10:37:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/compare-two-internal-tables/m-p/8400799#M1644752</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-12-15T10:37:19Z</dc:date>
    </item>
    <item>
      <title>Re: Compare two internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/compare-two-internal-tables/m-p/8400800#M1644753</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The Simplest solution for your query is :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
LOOP AT ITAB1 INTO WA.
READ TABLE ITAB TRANSPORTING NO FIELD WITH KEY MATNR = WA1-MATNR AND MATKL = WA1-MATKL.
IF SY-SUBRC &amp;lt;&amp;gt; 0.
DELETE ITAB1 FROM WA.
ENDIF.
ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try it at your end.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Anmol.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Dec 2011 10:47:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/compare-two-internal-tables/m-p/8400800#M1644753</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-12-15T10:47:07Z</dc:date>
    </item>
  </channel>
</rss>

