<?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 table with key ... binary search - key sequence?! in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-binary-search-key-sequence/m-p/8279512#M1633668</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Clemens,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have also faced such a scenario many times wherein the problem of Sy-subrc = 4 occurs when the order of key fields while reading an internal table is shuffled.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Did you try by using the key word "Binary Search" since you are sorting the data ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Danish.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 22 Sep 2011 05:22:40 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2011-09-22T05:22:40Z</dc:date>
    <item>
      <title>read table with key ... binary search - key sequence?!</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-binary-search-key-sequence/m-p/8279508#M1633664</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;consider this scenario:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data:
  lt_mbew type table of mbew.
field-symbols:
  &amp;lt;mbew&amp;gt;  type mbew.
select matnr bwkey stprs into corresponding fields of table  lt_mbew where ...
sort lt_mbew by matnr bwkey.
read table lt_mbew assigning &amp;lt;mbew&amp;gt;
  with key
    bwkey = ...
    matnr = ...&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;fails sometimes (sy-subrc = 4).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;read table lt_mbew assigning &amp;lt;mbew&amp;gt;
  with key
    matnr = ...
    bwkey = ...&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;works correctly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Why? Could not explain from documentation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please explain, thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Clemens&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Sep 2011 20:39:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-binary-search-key-sequence/m-p/8279508#M1633664</guid>
      <dc:creator>Clemenss</dc:creator>
      <dc:date>2011-09-21T20:39:43Z</dc:date>
    </item>
    <item>
      <title>Re: read table with key ... binary search - key sequence?!</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-binary-search-key-sequence/m-p/8279509#M1633665</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Clemens,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The read of lt_mbew in the first block of code sometimes fails because you do not have the keys in the same order as the sort.  You have the internal table sorted by MATNR BWKEY.  However, you are reading by BWKEY MATNR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;/P&gt;&lt;P&gt;Rae Ellen Woytowiez&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Sep 2011 21:06:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-binary-search-key-sequence/m-p/8279509#M1633665</guid>
      <dc:creator>former_member182010</dc:creator>
      <dc:date>2011-09-21T21:06:38Z</dc:date>
    </item>
    <item>
      <title>Re: read table with key ... binary search - key sequence?!</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-binary-search-key-sequence/m-p/8279510#M1633666</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Clemens,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my view &lt;U&gt;it does not find the value in sorted array&lt;/U&gt; when key are not passed in same sequence as it was used for sorting...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In [binary search algorithm|http://en.wikipedia.org/wiki/Binary_search_algorithm] attempt is made to search a value within the array which was prepared internally by sorting key combination...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Krish&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Sep 2011 21:15:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-binary-search-key-sequence/m-p/8279510#M1633666</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-21T21:15:35Z</dc:date>
    </item>
    <item>
      <title>Re: read table with key ... binary search - key sequence?!</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-binary-search-key-sequence/m-p/8279511#M1633667</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Clemens,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Interesting one !!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;May be a linear search should have the fields in order( in itab ) while doing a read &lt;SPAN __jive_emoticon_name="wink"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my view it does not find the value in sorted array when key are not passed in same sequence as it was used for sorting...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To check this may be you can do the same thing without sorting the itab and check it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Keshav&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Sep 2011 03:49:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-binary-search-key-sequence/m-p/8279511#M1633667</guid>
      <dc:creator>kesavadas_thekkillath</dc:creator>
      <dc:date>2011-09-22T03:49:39Z</dc:date>
    </item>
    <item>
      <title>Re: read table with key ... binary search - key sequence?!</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-binary-search-key-sequence/m-p/8279512#M1633668</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Clemens,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have also faced such a scenario many times wherein the problem of Sy-subrc = 4 occurs when the order of key fields while reading an internal table is shuffled.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Did you try by using the key word "Binary Search" since you are sorting the data ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Danish.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Sep 2011 05:22:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-binary-search-key-sequence/m-p/8279512#M1633668</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-22T05:22:40Z</dc:date>
    </item>
    <item>
      <title>Re: read table with key ... binary search - key sequence?!</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-binary-search-key-sequence/m-p/8279513#M1633669</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;Check the code as follows...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data:&lt;/P&gt;&lt;P&gt;  lt_mbew type table of mbew,&lt;/P&gt;&lt;P&gt;  wa_mbew  type mbew.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select matnr bwkey stprs into corresponding fields of table  lt_mbew where ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sort lt_mbew by matnr bwkey.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;read table lt_mbew into wa_mbew&lt;/P&gt;&lt;P&gt;  with key&lt;/P&gt;&lt;P&gt;        matnr = ...&lt;/P&gt;&lt;P&gt;        bwkey = ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ram.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Sep 2011 05:42:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-binary-search-key-sequence/m-p/8279513#M1633669</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-22T05:42:13Z</dc:date>
    </item>
    <item>
      <title>Re: read table with key ... binary search - key sequence?!</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-binary-search-key-sequence/m-p/8279514#M1633670</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is written in the documentation&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;For the binary search, the table must be sorted by the specified search key in ascending order. Otherwise the search will not find the correct row. &lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Else the algorithm will fail.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sorted table&lt;/P&gt;&lt;P&gt;A1&lt;/P&gt;&lt;P&gt;A2&lt;/P&gt;&lt;P&gt;B1&lt;/P&gt;&lt;P&gt;C2&lt;/P&gt;&lt;P&gt;D3&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Read with key 'C' '2'&lt;/P&gt;&lt;P&gt;first look at middle of table (record (1+5) / 2 = 3)&lt;/P&gt;&lt;P&gt;record 3 is less than 'C2' so &lt;/P&gt;&lt;P&gt;look at next half (record = (3 + 5) / 2 = 4)&lt;/P&gt;&lt;P&gt;record is 'C2' -&amp;gt; found&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;not sorted table - actual key value (expected key value)&lt;/P&gt;&lt;P&gt;1C (C1)&lt;/P&gt;&lt;P&gt;2C (C2)&lt;/P&gt;&lt;P&gt;2B (B2)&lt;/P&gt;&lt;P&gt;3D (D3)&lt;/P&gt;&lt;P&gt;3E (E3)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Read with key 'C' '2' and not ''2' 'C'&lt;/P&gt;&lt;P&gt;first look at middle of table&lt;/P&gt;&lt;P&gt;record 3 is less than 'C2' so &lt;/P&gt;&lt;P&gt;look at next half&lt;/P&gt;&lt;P&gt;record is 'D3' &lt;/P&gt;&lt;P&gt;look for half between 3 and 4, no more record -&amp;gt; not found&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>Thu, 22 Sep 2011 08:58:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-binary-search-key-sequence/m-p/8279514#M1633670</guid>
      <dc:creator>RaymondGiuseppi</dc:creator>
      <dc:date>2011-09-22T08:58:17Z</dc:date>
    </item>
    <item>
      <title>Re: read table with key ... binary search - key sequence?!</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-binary-search-key-sequence/m-p/8279515#M1633671</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Raymond,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the binary search, the table must be sorted by the specified search key in ascending order. Otherwise the search will not find the correct row. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But Clemens is not using a binary search in his code,its just a linear search.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kesav&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Sep 2011 09:05:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-binary-search-key-sequence/m-p/8279515#M1633671</guid>
      <dc:creator>kesavadas_thekkillath</dc:creator>
      <dc:date>2011-09-22T09:05:17Z</dc:date>
    </item>
    <item>
      <title>Re: read table with key ... binary search - key sequence?!</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-binary-search-key-sequence/m-p/8279516#M1633672</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think he is, judging by the topic name&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;read table with key ... binary search - key sequence?!   &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;possibly he left out the BINARY SEARCH in his examples.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And like raymond stated: you need to stick to the order of the key fields in order to have binary search working.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Maen Anachronos on Sep 22, 2011 11:49 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Sep 2011 09:48:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-binary-search-key-sequence/m-p/8279516#M1633672</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-22T09:48:48Z</dc:date>
    </item>
    <item>
      <title>Re: read table with key ... binary search - key sequence?!</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-binary-search-key-sequence/m-p/8279517#M1633673</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes i was referring to the thread header, I never get this error when using a linear search, else that would be an Abap "Big Bug", no ?&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>Thu, 22 Sep 2011 09:53:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-binary-search-key-sequence/m-p/8279517#M1633673</guid>
      <dc:creator>RaymondGiuseppi</dc:creator>
      <dc:date>2011-09-22T09:53:40Z</dc:date>
    </item>
    <item>
      <title>Re: read table with key ... binary search - key sequence?!</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-binary-search-key-sequence/m-p/8279518#M1633674</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Deleted..not relevant answer..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ravi.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: rshankar on Sep 23, 2011 10:57 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Sep 2011 09:58:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-binary-search-key-sequence/m-p/8279518#M1633674</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-22T09:58:15Z</dc:date>
    </item>
    <item>
      <title>Re: read table with key ... binary search - key sequence?!</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-binary-search-key-sequence/m-p/8279519#M1633675</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you look at Raymond's description on hwo BINARY SEARCH works then you should note that &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  with key
    bwkey = ...
    matnr = ...
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;causes the split first on BWKEY. Depending on the the contents of your internal table the split may occur incorrect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried it out with a simple ABAP and maybe it will help to understand what happens.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
types:  begin of ty_struct,
          field1 type C length 1,
          field2 type i,
        end of ty_struct.

data: it_struct type TABLE OF ty_struct.
data: wa_struct type ty_struct.
data: g_field1  type c length 1.
data: g_field2  type i.

wa_struct-field1 = 'A'. wa_struct-field2 = 0. append wa_struct to it_struct.
wa_struct-field1 = 'A'. wa_struct-field2 = 1. append wa_struct to it_struct.
wa_struct-field1 = 'A'. wa_struct-field2 = 6. append wa_struct to it_struct.

wa_struct-field1 = 'B'. wa_struct-field2 = 1. append wa_struct to it_struct.
wa_struct-field1 = 'B'. wa_struct-field2 = 4. append wa_struct to it_struct.
wa_struct-field1 = 'B'. wa_struct-field2 = 3. append wa_struct to it_struct.

wa_struct-field1 = 'C'. wa_struct-field2 = 7. append wa_struct to it_struct.
wa_struct-field1 = 'C'. wa_struct-field2 = 5. append wa_struct to it_struct.

wa_struct-field1 = 'D'. wa_struct-field2 = 1. append wa_struct to it_struct.
wa_struct-field1 = 'D'. wa_struct-field2 = 2. append wa_struct to it_struct.

sort it_struct by field1 field2.

g_field1 = 'C'.
g_field2 = 5.

loop at it_struct into wa_struct.
  write:/ wa_struct-field1, wa_struct-field2.
endloop.

skip 2.



write: /'Bin search FIELD1 FIELD2', g_field1, g_field2.
read table it_struct into wa_struct with key field1 = g_field1
                                             field2 = g_field2
                                             binary search.
if sy-subrc eq 0.
    write: / 'FOUND:', wa_struct-field1, wa_struct-field2.
else.
  write: / 'Not found'.
endif.

skip.

write: /'Bin search FIELD2 FIELD1', g_field2, g_field1.
read table it_struct into wa_struct with key field2 = g_field2
                                             field1 = g_field1
                                             binary search.
if sy-subrc eq 0.
    write: / 'FOUND:',  wa_struct-field1, wa_struct-field2.
else.
  write: / 'Not found'.
endif.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you run this example...both binary search gives you a hit. Now change the value of B 4 into B 6 and run it again.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Sep 2011 10:14:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-binary-search-key-sequence/m-p/8279519#M1633675</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-22T10:14:26Z</dc:date>
    </item>
    <item>
      <title>Re: read table with key ... binary search - key sequence?!</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-binary-search-key-sequence/m-p/8279520#M1633676</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Clemens,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is mentioned in the READ Table Documentation, found here: &lt;A href="http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb373d358411d1829f0000e829fbfe/frameset.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb373d358411d1829f0000e829fbfe/frameset.htm&lt;/A&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The standard table must be &lt;STRONG&gt;sorted in ascending order by the specified search key&lt;/STRONG&gt;. The BINARY SEARCH addition means that you can access an entry in a standard table by its key as quickly as you would be able to in a sorted table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since your Search Key is BWKEY and MATNR, your table must be sorted by BWKEY MATNR in this sequence. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Naimesh Patel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Sep 2011 13:23:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-binary-search-key-sequence/m-p/8279520#M1633676</guid>
      <dc:creator>naimesh_patel</dc:creator>
      <dc:date>2011-09-22T13:23:09Z</dc:date>
    </item>
    <item>
      <title>Re: read table with key ... binary search - key sequence?!</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-binary-search-key-sequence/m-p/8279521#M1633677</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you all!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes, it is in the documentation - the key sequence must be the same as the sort sequence.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyway, I changed it to a hashed table and read it WITH TABLE KEY. Still the best and fastest way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Clemens&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Sep 2011 22:03:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-binary-search-key-sequence/m-p/8279521#M1633677</guid>
      <dc:creator>Clemenss</dc:creator>
      <dc:date>2011-09-22T22:03:45Z</dc:date>
    </item>
  </channel>
</rss>

