<?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: Basic Question about SORTED TABLE in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/basic-question-about-sorted-table/m-p/484623#M16050</link>
    <description>&lt;P&gt;I've tried but I couldn't find the answer.&lt;/P&gt;
  &lt;P&gt;Well... I've searched again and find this in &lt;A href="https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-US/abapread_table_free.htm"&gt;READ TABLE - free_key &lt;/A&gt;&lt;BR /&gt;&lt;/P&gt;
  &lt;P&gt;The search runs as follows for the individual table categories, &lt;STRONG&gt;without&lt;/STRONG&gt; BINARY SEARCH being specified:&lt;/P&gt;
  &lt;UL&gt;
   &lt;LI&gt;&lt;BR /&gt;Sorted tables are sorted in a binary fashion if the specified search key is an initial part of the primary table key or includes this key; otherwise the search is linear.&lt;/LI&gt;
  &lt;/UL&gt;
  &lt;P&gt;So, I guess that yes, it's doing a binary search. &lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 28 Jul 2017 10:51:11 GMT</pubDate>
    <dc:creator>oliver_am</dc:creator>
    <dc:date>2017-07-28T10:51:11Z</dc:date>
    <item>
      <title>Basic Question about SORTED TABLE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/basic-question-about-sorted-table/m-p/484620#M16047</link>
      <description>&lt;P&gt;Hi, all.&lt;/P&gt;
  &lt;P&gt;I have a sorted table like this:&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;TYPES:  BEGIN OF line, 

 key TYPE char10,  

field1 TYPE char10,  

field2 TYPE char10,  

field3 TYPE char10,    

END OF line,

 my_table TYPE SORTED TABLE OF line WITH UNIQUE KEY key.&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;When I do a READ TABLE by the KEY field internally is doing a BINARY SEARCH, isn't it?&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;READ TABLE lt_my_table INTO ls_line WITH KEY key = '12345678'.&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;What happens if I do the READ with the KEY field and other fields too ? is doing also a BINARY SEARCH?&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;READ TABLE lt_my_table INTO ls_line WITH KEY key = '12345678'

                                             field1 = '99999'.&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2017 09:59:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/basic-question-about-sorted-table/m-p/484620#M16047</guid>
      <dc:creator>oliver_am</dc:creator>
      <dc:date>2017-07-28T09:59:50Z</dc:date>
    </item>
    <item>
      <title>Re: Basic Question about SORTED TABLE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/basic-question-about-sorted-table/m-p/484621#M16048</link>
      <description>&lt;P&gt;No it's not. It is using the key tree of the table.&lt;/P&gt;
  &lt;P&gt;When you read this table you should use this form of the Read statement:&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;READ TABLE lt_my_table INTO ls_line WITH TABLE KEY key='12345678'.&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;A Binary Chop is used on a standard table that has been sorted into an order based upon a field and the Read statement would like something like:&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;READ TABLE lt_my_table 
      INTO ls_line 
      WITH KEY key='12345678'
     BINARY SEARCH.
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;the key field specified must be the field used to sort the table initially.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2017 10:16:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/basic-question-about-sorted-table/m-p/484621#M16048</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2017-07-28T10:16:24Z</dc:date>
    </item>
    <item>
      <title>Re: Basic Question about SORTED TABLE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/basic-question-about-sorted-table/m-p/484622#M16049</link>
      <description>&lt;P&gt;Read the documentation for READ ...&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2017 10:22:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/basic-question-about-sorted-table/m-p/484622#M16049</guid>
      <dc:creator>retired_member</dc:creator>
      <dc:date>2017-07-28T10:22:26Z</dc:date>
    </item>
    <item>
      <title>Re: Basic Question about SORTED TABLE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/basic-question-about-sorted-table/m-p/484623#M16050</link>
      <description>&lt;P&gt;I've tried but I couldn't find the answer.&lt;/P&gt;
  &lt;P&gt;Well... I've searched again and find this in &lt;A href="https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-US/abapread_table_free.htm"&gt;READ TABLE - free_key &lt;/A&gt;&lt;BR /&gt;&lt;/P&gt;
  &lt;P&gt;The search runs as follows for the individual table categories, &lt;STRONG&gt;without&lt;/STRONG&gt; BINARY SEARCH being specified:&lt;/P&gt;
  &lt;UL&gt;
   &lt;LI&gt;&lt;BR /&gt;Sorted tables are sorted in a binary fashion if the specified search key is an initial part of the primary table key or includes this key; otherwise the search is linear.&lt;/LI&gt;
  &lt;/UL&gt;
  &lt;P&gt;So, I guess that yes, it's doing a binary search. &lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2017 10:51:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/basic-question-about-sorted-table/m-p/484623#M16050</guid>
      <dc:creator>oliver_am</dc:creator>
      <dc:date>2017-07-28T10:51:11Z</dc:date>
    </item>
    <item>
      <title>Re: Basic Question about SORTED TABLE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/basic-question-about-sorted-table/m-p/484624#M16051</link>
      <description>&lt;P&gt;There are three ways of accessing an internal table with READ TABLE. Index access and two accesses via search:&lt;/P&gt;
  &lt;UL&gt;
   &lt;LI&gt;&lt;A href="https://help.sap.com/http.svc/rc/abapdocu_751_index_htm/7.51/en-US/index.htm?file=abapread_table_key.htm"&gt;access via table key&lt;/A&gt;&lt;/LI&gt;
   &lt;LI&gt;&lt;A href="https://help.sap.com/http.svc/rc/abapdocu_751_index_htm/7.51/en-US/index.htm?file=abapread_table_free.htm"&gt;access via free key&lt;/A&gt;&lt;/LI&gt;
  &lt;/UL&gt;
  &lt;P&gt;The linked documentation explains how the different table kinds (and secondary keys) are treated.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2017 11:07:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/basic-question-about-sorted-table/m-p/484624#M16051</guid>
      <dc:creator>retired_member</dc:creator>
      <dc:date>2017-07-28T11:07:15Z</dc:date>
    </item>
    <item>
      <title>Re: Basic Question about SORTED TABLE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/basic-question-about-sorted-table/m-p/484625#M16052</link>
      <description>&lt;P&gt;IMHO you're asking a wrong question. You simply need to know when to use the appropriate table types. If you are reading a table with a key then use HASHED table type, not SORTED. (And now we can even create indexes for internal tables.) SORTED is more beneficial for reading with a LOOP. &lt;/P&gt;
  &lt;P&gt;BINARY SEARCH is really rather a thing of the past these days. I have not used it for years. Even if it actually used by the system in background I don't feel it's relevant or important.&lt;/P&gt;
  &lt;P&gt;This has been covered on SCN a lot, might want to search for existing posts.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2017 20:06:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/basic-question-about-sorted-table/m-p/484625#M16052</guid>
      <dc:creator>Jelena_Perfiljeva</dc:creator>
      <dc:date>2017-07-28T20:06:42Z</dc:date>
    </item>
    <item>
      <title>Re: Basic Question about SORTED TABLE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/basic-question-about-sorted-table/m-p/484626#M16053</link>
      <description>&lt;P&gt;"If you are reading a table with a key then use HASHED table type, not SORTED".&lt;/P&gt;
  &lt;P&gt;Hmm, that is a little too short. Find a more elaborated recommendation &lt;A target="_blank" href="https://help.sap.com/http.svc/rc/abapdocu_751_index_htm/7.51/en-US/index.htm?file=abenselect_table_type_guidl.htm"&gt;here&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Sat, 29 Jul 2017 09:28:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/basic-question-about-sorted-table/m-p/484626#M16053</guid>
      <dc:creator>retired_member</dc:creator>
      <dc:date>2017-07-29T09:28:52Z</dc:date>
    </item>
    <item>
      <title>Re: Basic Question about SORTED TABLE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/basic-question-about-sorted-table/m-p/484627#M16054</link>
      <description>&lt;P&gt;You're right, it's doing a binary search because the free key (KEY+FIELD1) includes the primary table key of the internal table (KEY).&lt;/P&gt;
  &lt;P&gt;PS @Horst.Keller : I guess there's a little typo in the sentence mentioned by Oliver at &lt;A href="https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-US/abapread_table_free.htm"&gt;READ TABLE - free_key&lt;/A&gt; : "Sorted tables are sorted" should be "are read".&lt;/P&gt;</description>
      <pubDate>Sat, 29 Jul 2017 19:03:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/basic-question-about-sorted-table/m-p/484627#M16054</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2017-07-29T19:03:43Z</dc:date>
    </item>
    <item>
      <title>Re: Basic Question about SORTED TABLE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/basic-question-about-sorted-table/m-p/484628#M16055</link>
      <description>&lt;P&gt;TLDR &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Of course it's a simplification based on the OP's example. &lt;/P&gt;</description>
      <pubDate>Tue, 01 Aug 2017 21:29:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/basic-question-about-sorted-table/m-p/484628#M16055</guid>
      <dc:creator>Jelena_Perfiljeva</dc:creator>
      <dc:date>2017-08-01T21:29:20Z</dc:date>
    </item>
  </channel>
</rss>

