<?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: READ statement with binary search in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement-with-binary-search/m-p/3912154#M937952</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi, &lt;/P&gt;&lt;P&gt;if you are using binary search in your read statement then you need to sort the internal table in ascending order i.e. by default the sort statement does . But in between you have sorted the table in descending order then your read statement with binary search will not work. &lt;/P&gt;&lt;P&gt;Or if you want that your search should works fast, declare the internal table as sorted type and then you can use the binary search statement but in that case you can not put any sort statement on the table. &lt;/P&gt;&lt;P&gt;Or &lt;/P&gt;&lt;P&gt;In case you have to do sorting in descending order then you need to provide all the possible key fields to the read statement  read statement with key addition. So it will find the unique record with possible combination of key fields. &lt;/P&gt;&lt;P&gt;I hope this will solve your query.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 06 Jun 2008 09:22:58 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-06-06T09:22:58Z</dc:date>
    <item>
      <title>READ statement with binary search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement-with-binary-search/m-p/3912147#M937945</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;I know that while using the READ statement that we have to sort data and use BINARY SEARCH  for faster search.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a situation &lt;/P&gt;&lt;P&gt;following are internal table contents&lt;/P&gt;&lt;P&gt;belnr          agent    action&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;9000001   name1    BRW&lt;/P&gt;&lt;P&gt;9000001   name1    API&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;when i use READ statement with where condition (  ( belnr - 9000001 ) and  ( action = 'BRW' ) )  with binary search then the SY_SUBRC value is 4.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if i remove the binary search then its giving SY-SUBRC value 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anybody explain why BINARY SEARCH fails.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Points will be rewarded for correct answers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks and regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Murthy&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Jun 2008 07:28:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement-with-binary-search/m-p/3912147#M937945</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-06T07:28:31Z</dc:date>
    </item>
    <item>
      <title>Re: READ statement with binary search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement-with-binary-search/m-p/3912148#M937946</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes,&lt;/P&gt;&lt;P&gt;U need to sort the data first on the key fields you are using.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Jun 2008 07:30:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement-with-binary-search/m-p/3912148#M937946</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-06T07:30:02Z</dc:date>
    </item>
    <item>
      <title>Re: READ statement with binary search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement-with-binary-search/m-p/3912149#M937947</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;check on which field u r sorting&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;u have to sort the internal table by belnr and action.&lt;/P&gt;&lt;P&gt;sort itab by belnr action.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;lavanya&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Jun 2008 07:33:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement-with-binary-search/m-p/3912149#M937947</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-06T07:33:26Z</dc:date>
    </item>
    <item>
      <title>Re: READ statement with binary search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement-with-binary-search/m-p/3912150#M937948</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;Thanks for your quick response.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried with belnr and action too. but it fails .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks and Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Jun 2008 08:25:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement-with-binary-search/m-p/3912150#M937948</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-06T08:25:29Z</dc:date>
    </item>
    <item>
      <title>Re: READ statement with binary search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement-with-binary-search/m-p/3912151#M937949</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You may need to change the internal table structure to: -&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;9000001 BRW name1&lt;/P&gt;&lt;P&gt;9000001 API name1&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Jun 2008 08:28:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement-with-binary-search/m-p/3912151#M937949</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-06T08:28:27Z</dc:date>
    </item>
    <item>
      <title>Re: READ statement with binary search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement-with-binary-search/m-p/3912152#M937950</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;try this i am not getting sy-subrc 4&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TYPES:BEGIN OF TY_ITAB,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BELNR TYPE BELNR,&lt;/P&gt;&lt;P&gt;AGENT(30),&lt;/P&gt;&lt;P&gt;ACTION(5),&lt;/P&gt;&lt;P&gt;END OF TY_ITAB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA:IT_TAB TYPE TABLE OF TY_ITAB,&lt;/P&gt;&lt;P&gt;     WA_TAB TYPE TY_ITAB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WA_TAB-BELNR = 9000001.&lt;/P&gt;&lt;P&gt;WA_TAB-AGENT = 'name1'.&lt;/P&gt;&lt;P&gt;WA_TAB-ACTION = 'BRW'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;APPEND WA_TAB TO IT_TAB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLEAR WA_TAB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WA_TAB-BELNR = 9000002.&lt;/P&gt;&lt;P&gt;WA_TAB-AGENT = 'name 2'.&lt;/P&gt;&lt;P&gt;WA_TAB-ACTION = 'API'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;APPEND WA_TAB TO IT_TAB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at it_tab into wa_tab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;read table it_tab into wa_tab with key belnr = wa_tab-belnr  binary search .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;write: sy-subrc, wa_tab-agent.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Jun 2008 09:04:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement-with-binary-search/m-p/3912152#M937950</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-06T09:04:16Z</dc:date>
    </item>
    <item>
      <title>Re: READ statement with binary search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement-with-binary-search/m-p/3912153#M937951</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You have sorted with 3 fields..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;field1, field2, field3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then u can use any of these combinations for reading with binary search&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;field1&lt;/P&gt;&lt;P&gt;field1 and field2&lt;/P&gt;&lt;P&gt;field1 and field2 and field3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;other than this u cannot use any combination.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;solution is to change the internal table strcture or sort using the required fields only.. in ur case field1 and field3.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Jun 2008 09:13:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement-with-binary-search/m-p/3912153#M937951</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-06T09:13:40Z</dc:date>
    </item>
    <item>
      <title>Re: READ statement with binary search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement-with-binary-search/m-p/3912154#M937952</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi, &lt;/P&gt;&lt;P&gt;if you are using binary search in your read statement then you need to sort the internal table in ascending order i.e. by default the sort statement does . But in between you have sorted the table in descending order then your read statement with binary search will not work. &lt;/P&gt;&lt;P&gt;Or if you want that your search should works fast, declare the internal table as sorted type and then you can use the binary search statement but in that case you can not put any sort statement on the table. &lt;/P&gt;&lt;P&gt;Or &lt;/P&gt;&lt;P&gt;In case you have to do sorting in descending order then you need to provide all the possible key fields to the read statement  read statement with key addition. So it will find the unique record with possible combination of key fields. &lt;/P&gt;&lt;P&gt;I hope this will solve your query.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Jun 2008 09:22:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement-with-binary-search/m-p/3912154#M937952</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-06T09:22:58Z</dc:date>
    </item>
    <item>
      <title>Re: READ statement with binary search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement-with-binary-search/m-p/3912155#M937953</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey its simple...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Internal table - i_tab (say)&lt;/P&gt;&lt;P&gt;belnr agent action&lt;/P&gt;&lt;P&gt;9000001 name1 BRW&lt;/P&gt;&lt;P&gt;9000001 name1 API&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you need to sort itab:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;sort i_tab by belnr action.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now you can read it:&lt;/P&gt;&lt;P&gt;Read table i_tab into wa_tab with key belnr = '9000001' action = 'BRW'  binary search.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards, Tapas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Jun 2008 09:23:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement-with-binary-search/m-p/3912155#M937953</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-06T09:23:08Z</dc:date>
    </item>
  </channel>
</rss>

