<?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: Regarding Binary Search to Read Table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-binary-search-to-read-table/m-p/9143565#M1709748</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Aswatha,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but is it mandatory to use numeric fields as search criteria, to use Binary Search? or any type of field (char, numc &amp;amp; int) can be the criteria.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 07 Dec 2012 18:30:56 GMT</pubDate>
    <dc:creator>arun_purohit</dc:creator>
    <dc:date>2012-12-07T18:30:56Z</dc:date>
    <item>
      <title>Regarding Binary Search to Read Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-binary-search-to-read-table/m-p/9143560#M1709743</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear ABAP Experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a question regarding Binary Search for reading an internal table.&lt;/P&gt;&lt;P&gt;Following are my points of query-&lt;/P&gt;&lt;P&gt;1) As per my understanding, we can use Binary Search only if parameter used with "WITH KEY" clause is a numeric field and internal table is sorted. Please correct me if I am wrong.&lt;/P&gt;&lt;P&gt;2) I have tried using Binary Search with sorted tables, but some times it has given unexpected incorrect results. Not sure what went wrong.&lt;/P&gt;&lt;P&gt;3) Is it possible to read an internal table with 8-9 fields (most of them are non-numeric) with "WITH KEY" clause using Binary Search.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Arun Purohit&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;&lt;STRONG&gt;Moderator message: covered by ABAP documentation -&amp;gt; question status removed&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Thomas Zloch&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Dec 2012 18:04:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-binary-search-to-read-table/m-p/9143560#M1709743</guid>
      <dc:creator>arun_purohit</dc:creator>
      <dc:date>2012-12-07T18:04:59Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding Binary Search to Read Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-binary-search-to-read-table/m-p/9143561#M1709744</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;First and most important condition you need to sort the internal table before using the read table..binaary search..&lt;/P&gt;&lt;P&gt;Use the reaad key field in the correct formate.. check the sy-subrc aafter reading the internal table.&lt;/P&gt;&lt;P&gt;You can use 8-9 field in the reaad table&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Dec 2012 18:19:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-binary-search-to-read-table/m-p/9143561#M1709744</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-12-07T18:19:54Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding Binary Search to Read Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-binary-search-to-read-table/m-p/9143562#M1709745</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks for promt reply,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;can we use Binary Search, even though table doesn't contain numeric fields?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Dec 2012 18:22:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-binary-search-to-read-table/m-p/9143562#M1709745</guid>
      <dc:creator>arun_purohit</dc:creator>
      <dc:date>2012-12-07T18:22:45Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding Binary Search to Read Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-binary-search-to-read-table/m-p/9143563#M1709746</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;First of all to use binary search the internal table should be sorted as you already know. There are other things you should know. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1&amp;gt; Before using binary search you need to sort the table by the keys that you use while searching using read table.&lt;/P&gt;&lt;P&gt;2&amp;gt;The order of keys used for sort must be same as the keys used to read the table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Eg: suppose ITAB has 4 fields. Field1, field2, field3 and field4. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and you want to read the table using Field1 and field2 in this order.&lt;/P&gt;&lt;P&gt;READ TABLE itab INTO wa WITH KEY field1 = val1 field2 = val2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then you should sort your table before reading like this.&lt;/P&gt;&lt;P&gt;SORT itab by field1 field2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope its clear.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Dec 2012 18:24:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-binary-search-to-read-table/m-p/9143563#M1709746</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-12-07T18:24:16Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding Binary Search to Read Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-binary-search-to-read-table/m-p/9143564#M1709747</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Arun,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The keys don't need to be numeric, but the table does need to be &lt;STRONG&gt;sorted in ascending order&lt;/STRONG&gt; according to the specified search key(s). There is some documentation on binary search &lt;A href="http://help.sap.com/abapdocu_702/en/abapread_table_free.htm"&gt;here&lt;/A&gt;. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;BR /&gt;Amy&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Dec 2012 18:29:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-binary-search-to-read-table/m-p/9143564#M1709747</guid>
      <dc:creator>amy_king</dc:creator>
      <dc:date>2012-12-07T18:29:14Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding Binary Search to Read Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-binary-search-to-read-table/m-p/9143565#M1709748</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Aswatha,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but is it mandatory to use numeric fields as search criteria, to use Binary Search? or any type of field (char, numc &amp;amp; int) can be the criteria.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Dec 2012 18:30:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-binary-search-to-read-table/m-p/9143565#M1709748</guid>
      <dc:creator>arun_purohit</dc:creator>
      <dc:date>2012-12-07T18:30:56Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding Binary Search to Read Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-binary-search-to-read-table/m-p/9143566#M1709749</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Amy.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Dec 2012 18:33:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-binary-search-to-read-table/m-p/9143566#M1709749</guid>
      <dc:creator>arun_purohit</dc:creator>
      <dc:date>2012-12-07T18:33:46Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding Binary Search to Read Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-binary-search-to-read-table/m-p/9143567#M1709750</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Amy ,&lt;/P&gt;&lt;P&gt;I have simple question for u i.e,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if we sort the internal table by two fields like&lt;/P&gt;&lt;P&gt;SORT ITAB BY FIELD1 FIELD2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then if we use only one key field in the read statement for binary search what will happen&lt;/P&gt;&lt;P&gt;and what is the diff in between them,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ex -&amp;nbsp; READ TABLE ITAB INTO WA WITH KEY FIELD2 - .......... BINARY SEARCH.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;what will happen ,&lt;/P&gt;&lt;P&gt;plz answer my question this is an interview question.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Jan 2015 10:17:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/regarding-binary-search-to-read-table/m-p/9143567#M1709750</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2015-01-14T10:17:33Z</dc:date>
    </item>
  </channel>
</rss>

