<?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 tables Using Binary Search in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/reading-internal-tables-using-binary-search/m-p/8905272#M1690198</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;Forget ABAP - just search for what BINARY SEARCH is in programming and you would be able to understand the logic behind the answers to your question. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Shravan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 23 Jul 2012 16:34:27 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2012-07-23T16:34:27Z</dc:date>
    <item>
      <title>Reading internal tables Using Binary Search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reading-internal-tables-using-binary-search/m-p/8905266#M1690192</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;i have a doubt when using BINARY SEARCH ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As SAP says in the link "&lt;A href="http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb373d358411d1829f0000e829fbfe/content.htm"&gt;http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb373d358411d1829f0000e829fbfe/content.htm&lt;/A&gt;" : &lt;/P&gt;&lt;P&gt;- "&lt;EM&gt;T&lt;SPAN style="color: #000000; font-family: Arial; font-size: small; text-align: -webkit-auto; background-color: #ffffff;"&gt;he standard table must be&lt;STRONG&gt; sorted in &lt;SPAN style="text-decoration: underline;"&gt;ascending order&lt;/SPAN&gt; by the &lt;SPAN style="text-decoration: underline;"&gt;specified search key&lt;/SPAN&gt;&lt;/STRONG&gt;."&lt;/SPAN&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Arial; font-size: small; text-align: -webkit-auto; background-color: #ffffff;"&gt;So my questions are :&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Arial; font-size: small; text-align: -webkit-auto; background-color: #ffffff;"&gt;1. Binary search do not work if we sort the table in Descending order ?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Arial; font-size: small; text-align: -webkit-auto; background-color: #ffffff;"&gt;2. In the sort case below: &lt;/SPAN&gt;&lt;SPAN style="background-color: #ffffff; color: #000000; font-family: Arial; font-size: small; text-align: -webkit-auto;"&gt;SORT itab BY matnr vtweg.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Can i directly Read the table with only the key matnr like below ? I mean, i don't need to sort again itab BY matnr (only)&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Arial; font-size: small; text-align: -webkit-auto; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; READ TABLE itab&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Arial; font-size: small; text-align: -webkit-auto; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ASSIGNING &amp;lt;fs_itab&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Arial; font-size: small; text-align: -webkit-auto; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WITH KEY &lt;SPAN style="color: #000000; font-family: Arial; font-size: small; text-align: -webkit-auto; background-color: #ffffff;"&gt;matnr = lv_matnr&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-align: -webkit-auto; color: #000000; font-size: small; background-color: #ffffff; font-family: Arial;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BINARY SEARCH.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-align: -webkit-auto; color: #000000; font-size: small; background-color: #ffffff; font-family: Arial;"&gt;My question is very basic but i think it is important to understand this concept ... hope to have an answer &lt;SPAN __jive_emoticon_name="wink" __jive_macro_name="emoticon" class="jive_macro jive_emote" src="https://community.sap.com/843/images/emoticons/wink.gif"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-align: -webkit-auto; color: #000000; font-size: small; background-color: #ffffff; font-family: Arial;"&gt;Thanks in advance&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-align: -webkit-auto; color: #000000; font-size: small; background-color: #ffffff; font-family: Arial;"&gt;Ainjaka&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jul 2012 12:13:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reading-internal-tables-using-binary-search/m-p/8905266#M1690192</guid>
      <dc:creator>ainjaka_narivelo</dc:creator>
      <dc:date>2012-07-23T12:13:35Z</dc:date>
    </item>
    <item>
      <title>Re: Reading internal tables Using Binary Search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reading-internal-tables-using-binary-search/m-p/8905267#M1690193</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;1) No. Binary Search won't work in case of Descending Sort.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) No. No need to sort again. This would work fine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks and Regards,&lt;/P&gt;&lt;P&gt;Chirag &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jul 2012 12:21:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reading-internal-tables-using-binary-search/m-p/8905267#M1690193</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-07-23T12:21:35Z</dc:date>
    </item>
    <item>
      <title>Re: Reading internal tables Using Binary Search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reading-internal-tables-using-binary-search/m-p/8905268#M1690194</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello &lt;SPAN style="color: #000000; font-family: Arial; font-size: small; text-align: -webkit-auto; background-color: #ffffff;"&gt;Ainjaka&lt;/SPAN&gt;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;as you mentioned it before, the BINARY SEARCH Option works only within the specified parameters.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You cannot use a READ TABLE on a table where the sorting is not ascending by the specified key and you will get a SY-SUBRC = 8 if a violation of the table has been found.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your case, you can only use "MATNR" as key if your table is sorted ascending because the binary search algorithm follows the key fields of the READ TABLE command. E.g. first search with MATNR - if there are no more fields, it takes the current result.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regard: You can get multiple results when you use an incomplete key.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Better use table types with "SORTED" or "HASHED" Option.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Hendrik&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jul 2012 12:24:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reading-internal-tables-using-binary-search/m-p/8905268#M1690194</guid>
      <dc:creator>hendrik_brandes</dc:creator>
      <dc:date>2012-07-23T12:24:12Z</dc:date>
    </item>
    <item>
      <title>Re: Reading internal tables Using Binary Search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reading-internal-tables-using-binary-search/m-p/8905269#M1690195</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;1. BINARY SEARCH doesn't work in descending.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Usually your SORT BY fields must be the same as your READ KEY fields. On your example it would be ok as you use only the first key fields. It would only dangerous if you use more READ KEY fields than what it is actually sorted.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jul 2012 12:27:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reading-internal-tables-using-binary-search/m-p/8905269#M1690195</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-07-23T12:27:33Z</dc:date>
    </item>
    <item>
      <title>Re: Reading internal tables Using Binary Search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reading-internal-tables-using-binary-search/m-p/8905270#M1690196</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ainjaka, although your doubt is already resolved above, I would like just to add an interesting link, hoping it helps you to clarify the concept around read table with binary search. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://friendlyabaper.blogspot.mx/2006/10/pure-and-simple-truth-about-binary.html"&gt;http://friendlyabaper.blogspot.mx/2006/10/pure-and-simple-truth-about-binary.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jul 2012 15:40:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reading-internal-tables-using-binary-search/m-p/8905270#M1690196</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-07-23T15:40:17Z</dc:date>
    </item>
    <item>
      <title>Re: Reading internal tables Using Binary Search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reading-internal-tables-using-binary-search/m-p/8905271#M1690197</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi C Z, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Statement 2. is only true if you are using binary search. If you are not then it does not matter whether it is sorted or not. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Shravan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jul 2012 16:31:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reading-internal-tables-using-binary-search/m-p/8905271#M1690197</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-07-23T16:31:37Z</dc:date>
    </item>
    <item>
      <title>Re: Reading internal tables Using Binary Search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reading-internal-tables-using-binary-search/m-p/8905272#M1690198</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;Forget ABAP - just search for what BINARY SEARCH is in programming and you would be able to understand the logic behind the answers to your question. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Shravan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jul 2012 16:34:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reading-internal-tables-using-binary-search/m-p/8905272#M1690198</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-07-23T16:34:27Z</dc:date>
    </item>
  </channel>
</rss>

