<?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 files in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-two-files/m-p/3023806#M714914</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;first sort both the internal tables using some sort key.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then check...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if itab1[] = itab2[].&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;.....&lt;/P&gt;&lt;P&gt;endif. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward if it is useful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Srinivas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 31 Oct 2007 22:32:47 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-10-31T22:32:47Z</dc:date>
    <item>
      <title>Comparing two files</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-two-files/m-p/3023804#M714912</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;My problem is I have two files with same structure, but may be having different data. I want to compare those files. I can read those files into two internal tables.&lt;/P&gt;&lt;P&gt;What is the fastest way to compare and determine the differences between the internal tables?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Aravind&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Oct 2007 21:43:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-two-files/m-p/3023804#M714912</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-31T21:43:11Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two files</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-two-files/m-p/3023805#M714913</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I guess you could read them into the two internal tables and sort them. Then loop through one table and read the corresponding record of the second table. Something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sort: itab1, itab2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab.&lt;/P&gt;&lt;P&gt;  read itab2 index sy-tabix.&lt;/P&gt;&lt;P&gt;  if itab1 &amp;lt;&amp;gt; itab2.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Do something.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  endif.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Oct 2007 21:46:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-two-files/m-p/3023805#M714913</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-31T21:46:35Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two files</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-two-files/m-p/3023806#M714914</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;first sort both the internal tables using some sort key.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then check...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if itab1[] = itab2[].&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;.....&lt;/P&gt;&lt;P&gt;endif. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward if it is useful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Srinivas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Oct 2007 22:32:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-two-files/m-p/3023806#M714914</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-31T22:32:47Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two files</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-two-files/m-p/3023807#M714915</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The following coding should be a guidline for an efficient compare of two internal table, using a hashed table for one of the two tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It assumes that there new lines, disappeared and chnages lines. &lt;/P&gt;&lt;P&gt;The three table ins_tab, del_tab, upd_tad collect the differences, they must be applied to itab1 to change it into itab2. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Siegfried&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
data:
  tab1     type tab,
  tab2     type hash.
  refresh  ins_tab.
  refresh  del_tab.
  refresh  upd_tab.

  tab1[] = itab1[].
  tab2[] = itab2[].
  clear wa1.
  clear wa2.


  loop at tab1 into wa1.
    read table tab2 into wa2
         with table key keyfield = wa1-keyfield.
    index1 = sy-tabix.

* entry not in itab2
    if ( sy-subrc ne 0 ).
      append wa1 to del_tab.

* entry in itab2, update if different
    else.
      delete table tab2
             with table key keyfield = wa1-keyfield.
      if ( wa1-ctext ne wa2-ctext ).
        append wa2 to upd_tab.
      endif.
    endif.
  endloop.

* in itab2 but not in itab1
  ins_tab[] = tab2[].

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Nov 2007 15:06:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/comparing-two-files/m-p/3023807#M714915</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-11-02T15:06:10Z</dc:date>
    </item>
  </channel>
</rss>

