<?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: Problem with Binary search. in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-binary-search/m-p/9433694#M1739424</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Deepti,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please SORT your table with KEY before you use it in READ with Binary Search.&lt;/P&gt;&lt;P&gt;This is the prerequisite with BINARY SEARCH, that your table must be SORTED before READ.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SORT itab by fld_xyz.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Read table itab with KEY fld_xyz = 'X'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this'll solve your issue.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 May 2013 06:59:42 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2013-05-15T06:59:42Z</dc:date>
    <item>
      <title>Problem with Binary search.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-binary-search/m-p/9433686#M1739416</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am looping and internal table, and reading the same internal table inside the loop when certain if conditions are satisfied.&lt;BR /&gt;The issue is the Read statement is not successful with the addition Binary search, even though is satifies all the if conditions.&lt;BR /&gt;It returns a sy-subrc value as 8.&lt;/P&gt;&lt;P&gt;When i remove the Binary search addition, the Read statement is successful with sy-subrc = 0. I&amp;nbsp; have sorted the internal table before the loop.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Can anyone explain why its happeing so?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 May 2013 11:50:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-binary-search/m-p/9433686#M1739416</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-05-10T11:50:45Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Binary search.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-binary-search/m-p/9433687#M1739417</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Define your tables as SORTED and a) you'll be using the more recent technology, introduced just 13 years ago... and b) you won't have BINARY SEARCH to add, so your problem will go away.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 May 2013 15:33:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-binary-search/m-p/9433687#M1739417</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2013-05-10T15:33:19Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Binary search.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-binary-search/m-p/9433688#M1739418</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The problem is probably why u are not using the SORT command before giving the command read.&lt;/P&gt;&lt;P&gt;Note: The sort command should be done for the condition of the field used in the read&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Puts the sort before&lt;/P&gt;&lt;P&gt;it_mara sort by ascending MATNR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Read table with key it_mara into wa_mara lsmara-MATNR MATNR = binary search.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 May 2013 15:50:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-binary-search/m-p/9433688#M1739418</guid>
      <dc:creator>ronaldo_aparecido</dc:creator>
      <dc:date>2013-05-10T15:50:32Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Binary search.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-binary-search/m-p/9433689#M1739419</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Option 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;define your internal table as sorted table &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ex : lt_table type sorted table of &amp;lt;structure/table ref&amp;gt; with key&amp;nbsp; -latest&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;option 2 :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Make sure you sorted your internal&amp;nbsp;&amp;nbsp; table with all the fields which you are using in read statement other wise read will fail .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 May 2013 16:00:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-binary-search/m-p/9433689#M1739419</guid>
      <dc:creator>kamesh_g</dc:creator>
      <dc:date>2013-05-10T16:00:05Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Binary search.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-binary-search/m-p/9433690#M1739420</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You have to sort your internal table by the fields that you're comparing in READ statement. Place the SORT statement just before the READ TABLE.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 May 2013 17:29:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-binary-search/m-p/9433690#M1739420</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-05-10T17:29:36Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Binary search.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-binary-search/m-p/9433691#M1739421</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just read the documentation of the &lt;A href="http://help.sap.com/abapdocu_731/en/abapread_table_free.htm#!ABAP_ONE_ADD@1@"&gt;BINARY SEARCH&lt;/A&gt; option, to understand.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Raymond&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 May 2013 11:32:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-binary-search/m-p/9433691#M1739421</guid>
      <dc:creator>RaymondGiuseppi</dc:creator>
      <dc:date>2013-05-13T11:32:16Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Binary search.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-binary-search/m-p/9433692#M1739422</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks experts, I got the solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The issue with my code was that, i had sorted the internal table with the specified keys in descending.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But Binary Search in the read statement works, only if the internal table is sorted with the same keys in the Read statement in Ascending order.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks Raymond for your link.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 May 2013 12:47:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-binary-search/m-p/9433692#M1739422</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-05-13T12:47:30Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Binary search.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-binary-search/m-p/9433693#M1739423</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;&lt;STRONG&gt;Text removed by moderator&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(And he couldn't give points as the post was unmarked as a question)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Matthew Billingham&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 May 2013 15:21:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-binary-search/m-p/9433693#M1739423</guid>
      <dc:creator>kamesh_g</dc:creator>
      <dc:date>2013-05-14T15:21:31Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Binary search.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-binary-search/m-p/9433694#M1739424</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Deepti,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please SORT your table with KEY before you use it in READ with Binary Search.&lt;/P&gt;&lt;P&gt;This is the prerequisite with BINARY SEARCH, that your table must be SORTED before READ.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SORT itab by fld_xyz.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Read table itab with KEY fld_xyz = 'X'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this'll solve your issue.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 May 2013 06:59:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-binary-search/m-p/9433694#M1739424</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-05-15T06:59:42Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Binary search.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-binary-search/m-p/9433695#M1739425</link>
      <description>&lt;P&gt;Yes, you are right. It is better to use SORT command exactly one line before the READ &amp;lt;ITAB&amp;gt; INTO &amp;lt;WA&amp;gt; WITH KEY &amp;lt;CONDITION&amp;gt; BINARY SEARCH&lt;/P&gt;&lt;P&gt;Reason: If the READ statement is used inside the loop, there may be chances that &amp;lt;ITAB&amp;gt; values gets added or removed and the sorting order of &amp;lt;ITAB&amp;gt; gets changed.  So every time the READ statement is accessed inside the loop, the SORT statement should be accessed every time to get the successful results(SY-SUBRC = 0). Otherwise, We will get error while accessing READ statement with BINARY SEARCH(SY-SUBRC = &lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2023 07:15:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-binary-search/m-p/9433695#M1739425</guid>
      <dc:creator>venusrini36</dc:creator>
      <dc:date>2023-10-26T07:15:25Z</dc:date>
    </item>
  </channel>
</rss>

