<?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: The difference from read table with &amp; without Binary search in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/the-difference-from-read-table-with-without-binary-search/m-p/1440258#M209512</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Boris,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;         BINAY SEARCH in READ will definitely increase performance.But &amp;lt;b&amp;gt;you need to SORT the internal table with all fields specifying in your READ statement&amp;lt;/b&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use the following statement before READ statement with BINARY SEARCH.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;SORT TKOMV BY KNUMV KPOSN KSCHL.&amp;lt;/b&amp;gt; &lt;/P&gt;&lt;P&gt;READ TABLE TKOMV WITH KEY KNUMV = GT_VBAK-KNUMV&lt;/P&gt;&lt;P&gt;KPOSN = GT_VBAP-POSNR&lt;/P&gt;&lt;P&gt;KSCHL = 'PR00'&lt;/P&gt;&lt;P&gt;BINARY SEARCH.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Vinay&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 20 Jun 2006 10:44:12 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-06-20T10:44:12Z</dc:date>
    <item>
      <title>The difference from read table with &amp; without Binary search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/the-difference-from-read-table-with-without-binary-search/m-p/1440257#M209511</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am confusing on using Binary search during read a internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example , I created a internal table called &amp;lt;b&amp;gt;TKOMV&amp;lt;/b&amp;gt;.&lt;/P&gt;&lt;P&gt;some of its content are as following. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;KNUMV ,,   KPOSN  ,,  STUNR  ,, ZAEHK ,,  KAPPL ,,  KSCHL ,,    KDATU&lt;/P&gt;&lt;P&gt;3174  ,,   000010 ,,   11 ,, 1 ,, V ,, PR00	   ,, 20051108&lt;/P&gt;&lt;P&gt;3174	,,  000010	,, 915 ,,	1	,, V	,, MWST ,,	20051226&lt;/P&gt;&lt;P&gt;3174 ,,	000010 ,,	940 ,,	1 ,,	V ,,	VPRS ,,	,, 20051108&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In case, i write the statement&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ TABLE TKOMV WITH KEY  KNUMV = GT_VBAK-KNUMV&lt;/P&gt;&lt;P&gt;                           KPOSN = GT_VBAP-POSNR&lt;/P&gt;&lt;P&gt;                           KSCHL = 'PR00'&lt;/P&gt;&lt;P&gt;                           BINARY SEARCH.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if GT_VBAK-KNUMV = 3174 , GT_VBAP-POSNR = 000010.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;sy-subrc will return 4!!!&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, If i write the statement without Binary search.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ TABLE TKOMV WITH KEY  KNUMV = GT_VBAK-KNUMV&lt;/P&gt;&lt;P&gt;                           KPOSN = GT_VBAP-POSNR&lt;/P&gt;&lt;P&gt;                           KSCHL = 'PR00'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if GT_VBAK-KNUMV = 3174 , GT_VBAP-POSNR = 000010.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;sy-subrc will return 0&amp;lt;/b&amp;gt; and find the appropriate record.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Why???&lt;/P&gt;&lt;P&gt;I know read table with binary search will consume less repsonse time.&lt;/P&gt;&lt;P&gt;But why it cannot find the appropriate record under this situation??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thx in advance for all of reply.&amp;lt;u&amp;gt;&amp;lt;/u&amp;gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Jun 2006 10:39:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/the-difference-from-read-table-with-without-binary-search/m-p/1440257#M209511</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-20T10:39:36Z</dc:date>
    </item>
    <item>
      <title>Re: The difference from read table with &amp; without Binary search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/the-difference-from-read-table-with-without-binary-search/m-p/1440258#M209512</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Boris,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;         BINAY SEARCH in READ will definitely increase performance.But &amp;lt;b&amp;gt;you need to SORT the internal table with all fields specifying in your READ statement&amp;lt;/b&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use the following statement before READ statement with BINARY SEARCH.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;SORT TKOMV BY KNUMV KPOSN KSCHL.&amp;lt;/b&amp;gt; &lt;/P&gt;&lt;P&gt;READ TABLE TKOMV WITH KEY KNUMV = GT_VBAK-KNUMV&lt;/P&gt;&lt;P&gt;KPOSN = GT_VBAP-POSNR&lt;/P&gt;&lt;P&gt;KSCHL = 'PR00'&lt;/P&gt;&lt;P&gt;BINARY SEARCH.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Vinay&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Jun 2006 10:44:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/the-difference-from-read-table-with-without-binary-search/m-p/1440258#M209512</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-20T10:44:12Z</dc:date>
    </item>
    <item>
      <title>Re: The difference from read table with &amp; without Binary search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/the-difference-from-read-table-with-without-binary-search/m-p/1440259#M209513</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;check if your table is sorted or not.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for binary search table must be sorted.&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;&lt;/P&gt;&lt;P&gt;Wasim Ahmed&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Jun 2006 10:44:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/the-difference-from-read-table-with-without-binary-search/m-p/1440259#M209513</guid>
      <dc:creator>dani_mn</dc:creator>
      <dc:date>2006-06-20T10:44:24Z</dc:date>
    </item>
    <item>
      <title>Re: The difference from read table with &amp; without Binary search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/the-difference-from-read-table-with-without-binary-search/m-p/1440260#M209514</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;binary search is one of the fastest way to find the record exists in the internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TO use BINARY SEARCH, you have to &amp;lt;b&amp;gt;SORT&amp;lt;/b&amp;gt; the &amp;lt;b&amp;gt;internal table&amp;lt;/b&amp;gt; in ASCENDING/DESCENDING ORDER. Then only you will get the exact results.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For more detail you can refer to below threads:&lt;/P&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_message" href="https://community.sap.com/" __jive_macro_name="message" modifiedtitle="true" __default_attr="1084944"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_message" href="https://community.sap.com/" __jive_macro_name="message" modifiedtitle="true" __default_attr="762027"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rgds,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Jun 2006 10:44:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/the-difference-from-read-table-with-without-binary-search/m-p/1440260#M209514</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-20T10:44:44Z</dc:date>
    </item>
    <item>
      <title>Re: The difference from read table with &amp; without Binary search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/the-difference-from-read-table-with-without-binary-search/m-p/1440261#M209515</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Before read table, sort table TKOMV by KNUMV KPOSN KSCHL.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Jun 2006 10:45:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/the-difference-from-read-table-with-without-binary-search/m-p/1440261#M209515</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-20T10:45:38Z</dc:date>
    </item>
    <item>
      <title>Re: The difference from read table with &amp; without Binary search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/the-difference-from-read-table-with-without-binary-search/m-p/1440262#M209516</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;&amp;lt;b&amp;gt;Before using Binary search Sort the internal Table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SORT TABLE TKOMV BY KNUMV KPOSN KSCHL.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;READ TABLE TKOMV WITH KEY KNUMV = GT_VBAK-KNUMV&lt;/P&gt;&lt;P&gt;KPOSN = GT_VBAP-POSNR&lt;/P&gt;&lt;P&gt;KSCHL = 'PR00'&lt;/P&gt;&lt;P&gt;BINARY SEARCH.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;May be it will be helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;reward points if helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- *****&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Jun 2006 10:45:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/the-difference-from-read-table-with-without-binary-search/m-p/1440262#M209516</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-20T10:45:47Z</dc:date>
    </item>
    <item>
      <title>Re: The difference from read table with &amp; without Binary search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/the-difference-from-read-table-with-without-binary-search/m-p/1440263#M209517</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Boris,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I faced the same problem.&lt;/P&gt;&lt;P&gt;when you use BINARY SEARCH the table you are reading should be sorted only then it will return the correct record&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sameena&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: sameena attarwala&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Jun 2006 10:46:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/the-difference-from-read-table-with-without-binary-search/m-p/1440263#M209517</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-20T10:46:07Z</dc:date>
    </item>
    <item>
      <title>Re: The difference from read table with &amp; without Binary search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/the-difference-from-read-table-with-without-binary-search/m-p/1440264#M209518</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Boris,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For using binary search, the internal table needs to be sorted. So, first sort the table and then use binary search.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Richa.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Jun 2006 10:46:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/the-difference-from-read-table-with-without-binary-search/m-p/1440264#M209518</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-20T10:46:18Z</dc:date>
    </item>
    <item>
      <title>Re: The difference from read table with &amp; without Binary search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/the-difference-from-read-table-with-without-binary-search/m-p/1440265#M209519</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;  Sort the internal table before using the read statement.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;beena&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Jun 2006 10:51:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/the-difference-from-read-table-with-without-binary-search/m-p/1440265#M209519</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-20T10:51:53Z</dc:date>
    </item>
    <item>
      <title>Re: The difference from read table with &amp; without Binary search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/the-difference-from-read-table-with-without-binary-search/m-p/1440266#M209520</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Boris&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just as guys have said, you have to sort your internal table before reading it:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: BEGIN OF ITAB OCCURS 0,&lt;/P&gt;&lt;P&gt;        FIELD1,&lt;/P&gt;&lt;P&gt;        FIELD2,&lt;/P&gt;&lt;P&gt;        .......&lt;/P&gt;&lt;P&gt;      END   OF ITAB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...........&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SORT ITAB BY FIELD1 FIELD2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ TABLE ITAB WITH KEY FIELD1 =&lt;/P&gt;&lt;P&gt;                         FIELD2 =   &lt;/P&gt;&lt;P&gt;                         BINARY SEARCH.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyway the performances improve only if the ITAB has many hits.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Max&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Jun 2006 10:53:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/the-difference-from-read-table-with-without-binary-search/m-p/1440266#M209520</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-20T10:53:15Z</dc:date>
    </item>
    <item>
      <title>Re: The difference from read table with &amp; without Binary search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/the-difference-from-read-table-with-without-binary-search/m-p/1440267#M209521</link>
      <description>&lt;P&gt;I have same query but when i am using binary search i am getting third record of the internal table and without binary search i am getting first record &lt;/P&gt;&lt;P&gt;can you please explain why &lt;/P&gt;</description>
      <pubDate>Tue, 19 Apr 2022 20:22:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/the-difference-from-read-table-with-without-binary-search/m-p/1440267#M209521</guid>
      <dc:creator>former_member778994</dc:creator>
      <dc:date>2022-04-19T20:22:00Z</dc:date>
    </item>
    <item>
      <title>Re: The difference from read table with &amp; without Binary search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/the-difference-from-read-table-with-without-binary-search/m-p/1440268#M209522</link>
      <description>&lt;P&gt;  &lt;SPAN class="mention-scrubbed"&gt;ravikumar.billa1&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;The answer is simple - you've not sorted your table correctly.&lt;/P&gt;&lt;P&gt;Use a SORTED table or a HASHED table. BINARY SEARCH is largely obsolete. This question was originally asked in 2006 and BINARY SEARCH was already obsolete then.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Apr 2022 10:17:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/the-difference-from-read-table-with-without-binary-search/m-p/1440268#M209522</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2022-04-20T10:17:47Z</dc:date>
    </item>
  </channel>
</rss>

