<?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 Problem with Binary search statement in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-binary-search-statement/m-p/1920951#M382622</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 problem with reading the internal with Binary search.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have two internal tables BSAS and BSIS. In BSAS I have 1,200,000 line items and BSIS 500,000 line items. I need to delete the line items if BSIS-BELNR NE BSAS-AUGBL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using the following code :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    LOOP AT gt_bsas .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      READ TABLE gt_bsis WITH KEY bukrs = gt_bsas-bukrs&lt;/P&gt;&lt;P&gt;                                  belnr = gt_bsas-augbl&lt;/P&gt;&lt;P&gt;                                  gjahr = gt_bsas-gjahr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      IF sy-subrc NE 0.&lt;/P&gt;&lt;P&gt;        DELETE gt_bsas.&lt;/P&gt;&lt;P&gt;        CLEAR  gt_bsas.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      ELSE.&lt;/P&gt;&lt;P&gt;      -&lt;/P&gt;&lt;HR originaltext="-----------------------" /&gt;&lt;P&gt;     endif.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;By this execution of the loop is taking long time. If I use the binary search it is fast but result is not correct.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please suggest me, how to resolve this issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Sri.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 16 Feb 2007 14:55:01 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-02-16T14:55:01Z</dc:date>
    <item>
      <title>Problem with Binary search statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-binary-search-statement/m-p/1920951#M382622</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 problem with reading the internal with Binary search.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have two internal tables BSAS and BSIS. In BSAS I have 1,200,000 line items and BSIS 500,000 line items. I need to delete the line items if BSIS-BELNR NE BSAS-AUGBL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using the following code :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    LOOP AT gt_bsas .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      READ TABLE gt_bsis WITH KEY bukrs = gt_bsas-bukrs&lt;/P&gt;&lt;P&gt;                                  belnr = gt_bsas-augbl&lt;/P&gt;&lt;P&gt;                                  gjahr = gt_bsas-gjahr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      IF sy-subrc NE 0.&lt;/P&gt;&lt;P&gt;        DELETE gt_bsas.&lt;/P&gt;&lt;P&gt;        CLEAR  gt_bsas.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      ELSE.&lt;/P&gt;&lt;P&gt;      -&lt;/P&gt;&lt;HR originaltext="-----------------------" /&gt;&lt;P&gt;     endif.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;By this execution of the loop is taking long time. If I use the binary search it is fast but result is not correct.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please suggest me, how to resolve this issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Sri.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Feb 2007 14:55:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-binary-search-statement/m-p/1920951#M382622</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-16T14:55:01Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Binary search statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-binary-search-statement/m-p/1920952#M382623</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI Sriram,&lt;/P&gt;&lt;P&gt;  The read statement should not be used in conjunction with the NOT EQUALS operator.&lt;/P&gt;&lt;P&gt;REad return one record if the ocndition matches.&lt;/P&gt;&lt;P&gt;There will be definitely more than ONE record for NOT EQUALS condition.&lt;/P&gt;&lt;P&gt;Hence it is not only taking so much time, but also is wrong usage.&lt;/P&gt;&lt;P&gt;REgards,&lt;/P&gt;&lt;P&gt;Ravi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Feb 2007 14:56:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-binary-search-statement/m-p/1920952#M382623</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-16T14:56:59Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Binary search statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-binary-search-statement/m-p/1920953#M382624</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi collect the value of sy-tabix into variable&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DELETE gt_bsas index v_tabix.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT gt_bsas .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;v_tabix = sy-tabix.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ TABLE gt_bsis WITH KEY bukrs = gt_bsas-bukrs&lt;/P&gt;&lt;P&gt;belnr = gt_bsas-augbl&lt;/P&gt;&lt;P&gt;gjahr = gt_bsas-gjahr&lt;/P&gt;&lt;P&gt;binary search.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF sy-subrc NE 0.&lt;/P&gt;&lt;P&gt;DELETE gt_bsas index v_tabix.&lt;/P&gt;&lt;P&gt;CLEAR gt_bsas.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ELSE.&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-----------------------" /&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Feb 2007 14:57:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-binary-search-statement/m-p/1920953#M382624</guid>
      <dc:creator>rahulkavuri</dc:creator>
      <dc:date>2007-02-16T14:57:55Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Binary search statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-binary-search-statement/m-p/1920954#M382625</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi Sriram,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do this way..&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
data : v_tabix  like sy-tabix.

sort gt_bsas by &amp;lt;all Key Fields&amp;gt;.

 LOOP AT gt_bsas .

 v_tabix = sy-tabix.

READ TABLE gt_bsis WITH KEY bukrs = gt_bsas-bukrs
belnr = gt_bsas-augbl
gjahr = gt_bsas-gjahr.

IF sy-subrc NE 0.
*DELETE gt_bsas.
DELETE gt_bsas index v_tabix..
CLEAR gt_bsas.

ELSE.
------------------------
endif.
endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Feb 2007 14:58:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-binary-search-statement/m-p/1920954#M382625</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-16T14:58:45Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Binary search statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-binary-search-statement/m-p/1920955#M382626</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this way:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT gt_bsas .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;SORT GT_BSIS BY BUKRS BELNR GJAHR.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;READ TABLE gt_bsis WITH KEY bukrs = gt_bsas-bukrs&lt;/P&gt;&lt;P&gt;belnr = gt_bsas-augbl&lt;/P&gt;&lt;P&gt;gjahr = gt_bsas-gjahr&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;BINARY SEARCH.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;IF sy-subrc eq 0.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;****Do Nothing.&lt;/P&gt;&lt;P&gt;ELSE.&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;DELETE gt_bsas sy-tabix.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;CLEAR gt_bsas.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Also make sure that the KEY mentioned in READ statement follows the same seqeunce of gt_bsis structure.&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;Santosh&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: &lt;/P&gt;&lt;P&gt;        SKJ&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Feb 2007 15:02:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-binary-search-statement/m-p/1920955#M382626</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-16T15:02:11Z</dc:date>
    </item>
  </channel>
</rss>

