<?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: Looking for Optimized code... in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/looking-for-optimized-code/m-p/997928#M75672</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;On doing little more analysis, I found that there will be only one key for the Internal table and hence usign Sharath's solution!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks all again!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Sree&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 01 Jul 2005 12:47:11 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2005-07-01T12:47:11Z</dc:date>
    <item>
      <title>Looking for Optimized code...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/looking-for-optimized-code/m-p/997922#M75666</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 2 internal tables, say, A &amp;amp; B. The records in B is subset of records in A. Now I want to find out the set of records which are in A, but not in B. I'm planning to do like below(pseudocode). Any other optimized way possible?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP at A.&lt;/P&gt;&lt;P&gt;  READ table B (using binary search).&lt;/P&gt;&lt;P&gt;  IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt;      ...&lt;/P&gt;&lt;P&gt;  ELSE.&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;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;Sree&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jul 2005 10:58:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/looking-for-optimized-code/m-p/997922#M75666</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-07-01T10:58:12Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for Optimized code...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/looking-for-optimized-code/m-p/997923#M75667</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;If i assume that ur internal tables have a key field to identify the unique record for example material number.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Loop at itab2.&lt;/P&gt;&lt;P&gt;populate the key field value into a range table r_matnr&lt;/P&gt;&lt;P&gt;with other fields like opt = 'EQ' and sign = 'I'.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now u can use.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;delete itab1 where not matnr in r_matnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this is advisable if the entries are very high,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or ur code can be optimised as...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since ur saying that B is subset of A. (assuming that number of entries in B comparatively less than in A)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;u can do..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Loop at B.&lt;/P&gt;&lt;P&gt;Read table A (using binary search).&lt;/P&gt;&lt;P&gt;if sy-subrc eq 0.&lt;/P&gt;&lt;P&gt;delte table A index sy-tabix.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jul 2005 11:34:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/looking-for-optimized-code/m-p/997923#M75667</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-07-01T11:34:55Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for Optimized code...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/looking-for-optimized-code/m-p/997924#M75668</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sree,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;looks like , that there's nothing to optimize.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards Andreas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jul 2005 11:43:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/looking-for-optimized-code/m-p/997924#M75668</guid>
      <dc:creator>andreas_mann3</dc:creator>
      <dc:date>2005-07-01T11:43:56Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for Optimized code...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/looking-for-optimized-code/m-p/997925#M75669</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sree,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I stumbled around in the ABAP documentation trying to find a suitable command for a 'difference set' operation - because that is essentially what you are trying to achieve - but I did not succeed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Nevertheless when analyzing the computational complexity of your program one can say that it is very efficient.&lt;/P&gt;&lt;P&gt;Binary search is really fast (log(n) precisely) but can only be applied to comparable, ordered and properly sorted data. Assuming this is the case with B then your algorithm has a total complexity of n*log(n) which is good.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are nevertheless two optimizations I would like to present to you:&lt;/P&gt;&lt;P&gt;1. Do the binary search in the larger of the two tables and consequentially loop over the smaller one.&lt;/P&gt;&lt;P&gt;2. Concerning the 'target' of your operation: The entries that you search for (i.e. the ones that do not exist in both tables) will probably be written into a table C. It makes sense to create this table with an explicit initial size which is max(size(A),size(B))-min(size(A),size(B)) (pseudocoded, size(A) and size(B) of course in local variables &lt;SPAN __jive_emoticon_name="wink"&gt;&lt;/SPAN&gt; ) to prevent continuous memory allocation which is very time consuming in comparison to the search algorithm &lt;SPAN __jive_emoticon_name="wink"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Patrick&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jul 2005 11:50:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/looking-for-optimized-code/m-p/997925#M75669</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-07-01T11:50:44Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for Optimized code...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/looking-for-optimized-code/m-p/997926#M75670</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sharath,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using a ranges table is an impressive solution. And I think it is the best approach, primarily due to the fact that there's only one LOOP (to create a range).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sree: This is a good solution. You must try implementing it in case your internal table has a key comrpising a single field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Anand Mandalika.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jul 2005 12:08:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/looking-for-optimized-code/m-p/997926#M75670</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-07-01T12:08:43Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for Optimized code...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/looking-for-optimized-code/m-p/997927#M75671</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks you all! very interesting solutions I got which I was looking for !&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my case, I have to go with Patrik's suggestions as my table has 2 non-unique keys. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will keep the use of Ranges in my mind for some other place !&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;Sree&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jul 2005 12:39:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/looking-for-optimized-code/m-p/997927#M75671</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-07-01T12:39:49Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for Optimized code...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/looking-for-optimized-code/m-p/997928#M75672</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;On doing little more analysis, I found that there will be only one key for the Internal table and hence usign Sharath's solution!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks all again!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Sree&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jul 2005 12:47:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/looking-for-optimized-code/m-p/997928#M75672</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-07-01T12:47:11Z</dc:date>
    </item>
  </channel>
</rss>

