<?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: reading internal table with binary search in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/reading-internal-table-with-binary-search/m-p/4458756#M1056830</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;BINARY SEARCH is not obsolete. You can definitely use this.&lt;/P&gt;&lt;P&gt;This will improve the performance of the code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 05 Sep 2008 08:07:14 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-09-05T08:07:14Z</dc:date>
    <item>
      <title>reading internal table with binary search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reading-internal-table-with-binary-search/m-p/4458748#M1056822</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi friends,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;can u differentaite between the below 2 statements and suggest me which one to use.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;code :&lt;/P&gt;&lt;P&gt;    start-of-selection.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      select matnr&lt;/P&gt;&lt;P&gt;             ersda&lt;/P&gt;&lt;P&gt;             ernam&lt;/P&gt;&lt;P&gt;             from mara into&lt;/P&gt;&lt;P&gt;             table t_mara where&lt;/P&gt;&lt;P&gt;             matnr in s_matnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        if t_mara[] is not initial.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;         select matnr&lt;/P&gt;&lt;P&gt;                werks&lt;/P&gt;&lt;P&gt;                from marc into&lt;/P&gt;&lt;P&gt;                table t_marc&lt;/P&gt;&lt;P&gt;                for all entries in t_mara&lt;/P&gt;&lt;P&gt;                where matnr = t_mara-matnr.&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;        sort t_marc by matnr.&lt;/P&gt;&lt;P&gt;**********************************************************************&lt;/P&gt;&lt;P&gt;a)&lt;/P&gt;&lt;P&gt;         loop at t_mara into wa_mara.&lt;/P&gt;&lt;P&gt;            read table t_marc into wa_marc with key matnr = wa_mara-matnr binary search.&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;&lt;/P&gt;&lt;P&gt;b)   &lt;/P&gt;&lt;P&gt;        loop at t_mara into wa_mara.&lt;/P&gt;&lt;P&gt;            read table t_marc into wa_marc with key matnr = wa_mara-matnr .&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;can any one tell what exactly will happen if i use binary search and if i dnt use binary search.&lt;/P&gt;&lt;P&gt;which is preferable .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;PRIYANKA.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Sep 2008 07:42:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reading-internal-table-with-binary-search/m-p/4458748#M1056822</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-05T07:42:29Z</dc:date>
    </item>
    <item>
      <title>Re: reading internal table with binary search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reading-internal-table-with-binary-search/m-p/4458749#M1056823</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If t_marc is defined as a SORTED table with key MATNR, you can omit BINARY SEARCH and just read the table with TABLE KEY matnr.&lt;/P&gt;&lt;P&gt;If t_marc is a STANDARD table, you better sort it by MATNR and use BINARY SEARCH when accessing it.&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Sep 2008 07:44:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reading-internal-table-with-binary-search/m-p/4458749#M1056823</guid>
      <dc:creator>ThomasZloch</dc:creator>
      <dc:date>2008-09-05T07:44:25Z</dc:date>
    </item>
    <item>
      <title>Re: reading internal table with binary search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reading-internal-table-with-binary-search/m-p/4458750#M1056824</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Priyanka,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Its a good idea to SORT the internal table first and then read using Binary search.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sort the table on the key that will be used in the READ.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is helpful performance wise.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;reagrds,&lt;/P&gt;&lt;P&gt;Pranu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Sep 2008 07:49:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reading-internal-table-with-binary-search/m-p/4458750#M1056824</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-05T07:49:42Z</dc:date>
    </item>
    <item>
      <title>Re: reading internal table with binary search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reading-internal-table-with-binary-search/m-p/4458751#M1056825</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Priyanka,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at t_mara into wa_mara.&lt;/P&gt;&lt;P&gt;read table t_marc into wa_marc with key matnr = wa_mara-matnr binary search.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The above method is preferrable because &lt;STRONG&gt;Binary Search increases the performance.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Basically in the Binary Search process, the whole records are divided into two halves and based on the condition, ie., key it searchs only the correct half. So, our search time has been cut down to half of the time. Now the same process continues until the correct record is found. Every time it divides into two halves and searches only the correct half. So, our search time gradually reduces.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But we need to make sure that the table should be &lt;STRONG&gt;SORTED&lt;/STRONG&gt; on which the Binary Search is being performed. Otherwise, we may get wrong results.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this will help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Nitin.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Sep 2008 07:52:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reading-internal-table-with-binary-search/m-p/4458751#M1056825</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-05T07:52:46Z</dc:date>
    </item>
    <item>
      <title>Re: reading internal table with binary search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reading-internal-table-with-binary-search/m-p/4458752#M1056826</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Binary search is accelerates data selection from internal table.&lt;/P&gt;&lt;P&gt;The statement a) will be work faster.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Sep 2008 07:54:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reading-internal-table-with-binary-search/m-p/4458752#M1056826</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-05T07:54:09Z</dc:date>
    </item>
    <item>
      <title>Re: reading internal table with binary search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reading-internal-table-with-binary-search/m-p/4458753#M1056827</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;whenever you use BINARY SEARCH in read statement the search will be more faster and that improves the performance of the program a lot. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;here the only condition is the internal table must be SORTED on the fields which are used in READ.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your case..&lt;/P&gt;&lt;P&gt;sort t_marc by matnr.&lt;/P&gt;&lt;P&gt;**********************************************************************&lt;/P&gt;&lt;P&gt;a)&lt;/P&gt;&lt;P&gt;loop at t_mara into wa_mara.&lt;/P&gt;&lt;P&gt;read table t_marc into wa_marc with key matnr = wa_mara-matnr binary search.&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;the above code will reduce the no. of searches for a Material to root value of the no. of entires in the internal table like 10 searches for 100 entry table where as your option B code will take 100 searches.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so READ with BINARY SEARCH is always recommended.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Sep 2008 07:56:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reading-internal-table-with-binary-search/m-p/4458753#M1056827</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-05T07:56:51Z</dc:date>
    </item>
    <item>
      <title>Re: reading internal table with binary search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reading-internal-table-with-binary-search/m-p/4458754#M1056828</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Priyanka,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Binary Search is faster than Sequential Search.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;when you write &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
read table t_marc into wa_marc with key matnr = wa_mara-matnr .
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;It search the Internal table in a sequential manner, i.e, first record, second record ....last record, till it find the right value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But, if you write the code as &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
read table t_marc into wa_marc with key matnr = wa_mara-matnr binary search.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;It will search the internal table in BINARY search algorith. &lt;/P&gt;&lt;P&gt;Table has to sorted in ascending format before we do binary search.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In sequential search, the graph between number of records in the internal table Vs time taken is linear.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In Binary search, the graph between number of records in the internal table Vs time taken is logarithmic.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Sep 2008 08:00:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reading-internal-table-with-binary-search/m-p/4458754#M1056828</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-05T08:00:22Z</dc:date>
    </item>
    <item>
      <title>Re: reading internal table with binary search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reading-internal-table-with-binary-search/m-p/4458755#M1056829</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;we can use binary search one. i hope it is not an obsolute statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Iam i correct.....?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;PRIYANKA.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Sep 2008 08:03:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reading-internal-table-with-binary-search/m-p/4458755#M1056829</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-05T08:03:53Z</dc:date>
    </item>
    <item>
      <title>Re: reading internal table with binary search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reading-internal-table-with-binary-search/m-p/4458756#M1056830</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;BINARY SEARCH is not obsolete. You can definitely use this.&lt;/P&gt;&lt;P&gt;This will improve the performance of the code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Sep 2008 08:07:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reading-internal-table-with-binary-search/m-p/4458756#M1056830</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-05T08:07:14Z</dc:date>
    </item>
    <item>
      <title>Re: reading internal table with binary search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reading-internal-table-with-binary-search/m-p/4458757#M1056831</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;Yes, you are correct. Make use of A.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Sriram Ponna.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Sep 2008 08:12:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reading-internal-table-with-binary-search/m-p/4458757#M1056831</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-05T08:12:16Z</dc:date>
    </item>
  </channel>
</rss>

