<?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: reab table- binary search in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/reab-table-binary-search/m-p/6984323#M1493031</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;binary search will always return the first record in the internal table matching the search criteria. you can sort table by char or number or numeric fields and binary search will always return the first record if there are duplicates&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 22 Jun 2010 05:42:47 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2010-06-22T05:42:47Z</dc:date>
    <item>
      <title>reab table- binary search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reab-table-binary-search/m-p/6984319#M1493027</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;i have an internal table:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;types: begin of ty_mara,&lt;/P&gt;&lt;P&gt;                matnr type matnr,&lt;/P&gt;&lt;P&gt;                werks   type werks_d,&lt;/P&gt;&lt;P&gt;                lgort    type lgort,&lt;/P&gt;&lt;P&gt;                menge type menge,&lt;/P&gt;&lt;P&gt;           end of ty_mara.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: wa_mara type ty_mara,&lt;/P&gt;&lt;P&gt;         gt_mara type table of ty_mara with default key initial size 10.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;now i fill this gt_mara with data using select statement on different tables...&lt;/P&gt;&lt;P&gt;let's suppose i get 50000 records into table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sort gt_mara by matnr werks lgort.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;read table gt_mara into wa_mara with key matnr = '10000678' &lt;/P&gt;&lt;P&gt;                                                                     werks = 'CA01'&lt;/P&gt;&lt;P&gt;                                                                     lgort    = 'LT45'&lt;/P&gt;&lt;P&gt;                                                BINARY SEARCH.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if the internal table has 1000 (duplicate)entries with same key, will the read statement with binary search option bring the 1st record of this 1000 records? Is it assured?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note: I don't want to delete duplicate entries&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ravi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Jun 2010 04:22:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reab-table-binary-search/m-p/6984319#M1493027</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-06-22T04:22:36Z</dc:date>
    </item>
    <item>
      <title>Re: reab table- binary search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reab-table-binary-search/m-p/6984320#M1493028</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ravi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes it will pick up the first record encountered in the internal table.But how do you know that the record picked first is the one you are looking for?Because you are saying that you don't want to delete duplicate entries.Maintaining duplicate entries causes inconsistency.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Lakshman.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Jun 2010 04:29:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reab-table-binary-search/m-p/6984320#M1493028</guid>
      <dc:creator>former_member209217</dc:creator>
      <dc:date>2010-06-22T04:29:36Z</dc:date>
    </item>
    <item>
      <title>Re: reab table- binary search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reab-table-binary-search/m-p/6984321#M1493029</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;Yes your assumption is absolutely correct. It will always bring the very first matching record.&lt;/P&gt;&lt;P&gt;Now you are saying that in this case you dont want to loose the remaining same records. Is it so ? If yes then , &lt;/P&gt;&lt;P&gt;That mean you want to read all the 50000 records present in the table.&lt;/P&gt;&lt;P&gt;Then Read them on  the index basis.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Read table into wa index counter.&lt;/P&gt;&lt;P&gt;READ TABLE tab INDEX sy-index/counter INTO wa. &lt;/P&gt;&lt;P&gt;  IF sy-subrc = 0. &lt;/P&gt;&lt;P&gt;  --&lt;/P&gt;&lt;P&gt;  ENDIF. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;increment counter every time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this is helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Uma Dave&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: UmaDave on Jun 22, 2010 7:21 AM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: UmaDave on Jun 22, 2010 7:26 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Jun 2010 05:20:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reab-table-binary-search/m-p/6984321#M1493029</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-06-22T05:20:36Z</dc:date>
    </item>
    <item>
      <title>Re: reab table- binary search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reab-table-binary-search/m-p/6984322#M1493030</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Ravi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;     Let me explain Read statements in detail:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) Read table intenal_table into work_area with key = (the corresponding key).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        Here the table is searched upon this key. Upon finding the record with the specified key the sy-subrc is set to 0 and you process the record.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        This is mainly used to find if there exists a record with the search parameter you are passing in the read statement. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2)   Sort internal_table.&lt;/P&gt;&lt;P&gt;      Read table intenal_table into work_area with key = (the corresponding key) binary search.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;            Here too you search for a pariticular record with the search key but the search happens faster as you are sorting the internal table and you are searching based on BINARY SEARCH OPTION.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3)  &lt;EM&gt;If the intention is only to search fields and if no operation is to be performed please use this:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    &lt;STRONG&gt;Read table intenal_table into work_area with key = (the corresponding key) binary search transporting no fields.&lt;/STRONG&gt;  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;         This would yield the most responsive search result. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That was about the read statements. Now coming to your queires, &lt;U&gt;Yes it access the first record of the search parameter that satisifies the provided keys and to get to a particular record you need to pass the exact search key in order to avoid the loop and be specific interms of searching the particular record (Exact searh criterion).&lt;/U&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Shree Tejus.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Jun 2010 05:42:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reab-table-binary-search/m-p/6984322#M1493030</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-06-22T05:42:16Z</dc:date>
    </item>
    <item>
      <title>Re: reab table- binary search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reab-table-binary-search/m-p/6984323#M1493031</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;binary search will always return the first record in the internal table matching the search criteria. you can sort table by char or number or numeric fields and binary search will always return the first record if there are duplicates&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Jun 2010 05:42:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reab-table-binary-search/m-p/6984323#M1493031</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-06-22T05:42:47Z</dc:date>
    </item>
    <item>
      <title>Re: reab table- binary search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reab-table-binary-search/m-p/6984324#M1493032</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ravi,&lt;/P&gt;&lt;P&gt;           You cant be certain which record will be picked.It will bring any record matching the criterion.Because in simple read statement,sequential search is performed.But logic for binary search is different.Binary search repeatedly divides the search interval in half. If the value to be searched is less than the item in the middle of the interval, the search is narrowed to the lower half, otherwise the search is narrowed to the upper half. So any record can be picked.&lt;/P&gt;&lt;P&gt;Hope it helps&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;Vivek Kumar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Jun 2010 06:22:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reab-table-binary-search/m-p/6984324#M1493032</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-06-22T06:22:22Z</dc:date>
    </item>
    <item>
      <title>Re: reab table- binary search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reab-table-binary-search/m-p/6984325#M1493033</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This message was moderated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Dec 2010 13:32:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reab-table-binary-search/m-p/6984325#M1493033</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-12-03T13:32:33Z</dc:date>
    </item>
  </channel>
</rss>

