<?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 binary seach in internal table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/binary-seach-in-internal-table/m-p/1473996#M222444</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;if not sort inernal table table , what happend in binary seach&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 08 Aug 2006 04:22:44 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-08-08T04:22:44Z</dc:date>
    <item>
      <title>binary seach in internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/binary-seach-in-internal-table/m-p/1473996#M222444</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;if not sort inernal table table , what happend in binary seach&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Aug 2006 04:22:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/binary-seach-in-internal-table/m-p/1473996#M222444</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-08-08T04:22:44Z</dc:date>
    </item>
    <item>
      <title>Re: binary seach in internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/binary-seach-in-internal-table/m-p/1473997#M222445</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The binary search algorithm helps faster search of a value in an internal table. It is advisable to sort the internal table before doing a binary search. Binary search repeatedly divides the search interval in half. If the value to be searched is less than the item in the middle of the interval, the search is narrowed to the lower half, otherwise the search is narrowed to the upper half.&lt;/P&gt;&lt;P&gt;IF the int table is sorted by a key, then when BINARY SEARCH is added to a WITH KEY statement... the "read" to the int table is performed at a binary level for maximum performance.&lt;/P&gt;&lt;P&gt;if N is the number of entries in your itab, linear search is done in O(N) and binary search is done in O(logN).&lt;/P&gt;&lt;P&gt;use it if your itab is big, just don't forget to sort it if it's a standard table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Aug 2006 04:24:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/binary-seach-in-internal-table/m-p/1473997#M222445</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-08-08T04:24:28Z</dc:date>
    </item>
    <item>
      <title>Re: binary seach in internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/binary-seach-in-internal-table/m-p/1473998#M222446</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 the table is not sorted and you use Binary search then it will search the record start from 1st record. If 20 records are in internal table, then it will start from 1st record.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Instead if you sort the table, it will start from the middle. i.e. if 20 records are in internal table then it will start from 11th record upwards or downwards depending on the value. So the time required would be half the time of normal.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Prashant&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Aug 2006 04:26:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/binary-seach-in-internal-table/m-p/1473998#M222446</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-08-08T04:26:23Z</dc:date>
    </item>
    <item>
      <title>Re: binary seach in internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/binary-seach-in-internal-table/m-p/1473999#M222447</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;You must SORT internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Excample.&lt;/P&gt;&lt;P&gt;If you dont SORT properly defnetly BINARY SEARCH will failed.&lt;/P&gt;&lt;P&gt;Make sure to takecare the order of the fields on which you are sorting.&lt;/P&gt;&lt;P&gt;SORT itab by bukrs belnr gjahr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at it_itab.&lt;/P&gt;&lt;P&gt;clear itab.&lt;/P&gt;&lt;P&gt;read table itab with key bukrs = it_itab-bukrs&lt;/P&gt;&lt;P&gt;                         belnr = it_itab-belnr&lt;/P&gt;&lt;P&gt;                         gjahr = it_itab-gjahr.&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;Thanks.&lt;/P&gt;&lt;P&gt;If this helps you reward with points.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Aug 2006 04:27:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/binary-seach-in-internal-table/m-p/1473999#M222447</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-08-08T04:27:21Z</dc:date>
    </item>
  </channel>
</rss>

