<?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 binary search in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-binary-search/m-p/2205399#M471634</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Priya&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you need to add new entries to T_SPLIT within your loop then you could define this itab as &amp;lt;b&amp;gt;SORTED TABLE WITH UNIQUE KEY&amp;lt;/b&amp;gt; &amp;lt;i&amp;gt;matnr zwatctgp &amp;lt;/i&amp;gt;(I assume that this is possible. This means the itab cannot have duplicate entries for matnr zwatctgp ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;"SORT t_split BY matnr zwatctgp.  " obsolete if already SORTED TABLE
LOOP AT t_zwplccrimsr_hash.
READ TABLE t_split 
          WITH TABLE KEY matnr = t_zwplccrimsr_hash-matnr
                                zwatctgp = t_zwplccrimsr_hash-zwatctgp.

v_indx = sy-tabix .
IF sy-subrc &amp;lt;&amp;gt; 0.
MOVE-CORRESPONDING t_zwplccrimsr_hash TO t_split.
t_split-xloek = 'X'.
"APPEND t_split.
INSERT t_split INTO TABLE t_split.
CLEAR t_split.
ELSE.
IF t_split-zwstdt = t_zwplccrimsr_hash-zwstdt AND
t_split-zweddt = t_zwplccrimsr_hash-zweddt AND
t_split-xloek = ' '.
DELETE t_split INDEX v_indx .
ELSE.
t_split-zwcrus = t_zwplccrimsr_hash-zwcrus. "V001
t_split-zwcrdt = t_zwplccrimsr_hash-zwcrdt.
t_split-zwcrtm = t_zwplccrimsr_hash-zwcrtm.
t_split-zwchus = 'CREST'.
t_split-zwchdt = sy-datum.
t_split-zwchtm = sy-uzeit.

MODIFY t_split INDEX v_indx.
...&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;  Uwe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 25 Apr 2007 21:36:43 GMT</pubDate>
    <dc:creator>uwe_schieferstein</dc:creator>
    <dc:date>2007-04-25T21:36:43Z</dc:date>
    <item>
      <title>read table binary search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-binary-search/m-p/2205394#M471629</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all ,&lt;/P&gt;&lt;P&gt;This is my code .some how my read statement is not workng . Can any one tell me what will be the issue with read statement?&lt;/P&gt;&lt;P&gt;FORM delete_entries.&lt;/P&gt;&lt;P&gt;  DATA:v_indx LIKE sy-tabix.&lt;/P&gt;&lt;P&gt;*Get delete materials from zwplccrimsr table&lt;/P&gt;&lt;P&gt;  SORT t_split BY matnr zwatctgp.&lt;/P&gt;&lt;P&gt;  LOOP AT t_zwplccrimsr_hash.&lt;/P&gt;&lt;P&gt;    READ TABLE t_split WITH KEY matnr = t_zwplccrimsr_hash-matnr&lt;/P&gt;&lt;P&gt;                        zwatctgp = t_zwplccrimsr_hash-zwatctgp&lt;/P&gt;&lt;P&gt;                        BINARY SEARCH.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    v_indx = sy-tabix .&lt;/P&gt;&lt;P&gt;    IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;      MOVE-CORRESPONDING t_zwplccrimsr_hash TO t_split.&lt;/P&gt;&lt;P&gt;      t_split-xloek = 'X'.&lt;/P&gt;&lt;P&gt;      APPEND t_split.&lt;/P&gt;&lt;P&gt;      CLEAR t_split.&lt;/P&gt;&lt;P&gt;    ELSE.&lt;/P&gt;&lt;P&gt;      IF t_split-zwstdt = t_zwplccrimsr_hash-zwstdt AND&lt;/P&gt;&lt;P&gt;             t_split-zweddt = t_zwplccrimsr_hash-zweddt AND&lt;/P&gt;&lt;P&gt;             t_split-xloek = '  '.&lt;/P&gt;&lt;P&gt;        DELETE t_split INDEX v_indx .&lt;/P&gt;&lt;P&gt;      ELSE.&lt;/P&gt;&lt;P&gt;        t_split-zwcrus  = t_zwplccrimsr_hash-zwcrus.    "V001&lt;/P&gt;&lt;P&gt;        t_split-zwcrdt  = t_zwplccrimsr_hash-zwcrdt.&lt;/P&gt;&lt;P&gt;        t_split-zwcrtm  = t_zwplccrimsr_hash-zwcrtm.&lt;/P&gt;&lt;P&gt;        t_split-zwchus  = 'CREST'.&lt;/P&gt;&lt;P&gt;        t_split-zwchdt = sy-datum.&lt;/P&gt;&lt;P&gt;        t_split-zwchtm = sy-uzeit.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        MODIFY t_split INDEX v_indx.&lt;/P&gt;&lt;P&gt;      ENDIF.&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;P&gt;ENDFORM.                    "delete_entries&lt;/P&gt;&lt;P&gt;LINE&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Apr 2007 19:30:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-binary-search/m-p/2205394#M471629</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-04-25T19:30:34Z</dc:date>
    </item>
    <item>
      <title>Re: read table binary search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-binary-search/m-p/2205395#M471630</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Priya&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to use BINARY SEARCH then you have to sort your itab as you did:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;...
SORT t_split BY matnr zwatctgp.  " for BINARY SEARCH required
LOOP AT t_zwplccrimsr_hash.
  READ TABLE t_split 
            WITH KEY matnr = t_zwplccrimsr_hash-matnr
                        zwatctgp = t_zwplccrimsr_hash-zwatctgp
            BINARY SEARCH.
...&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, within the loop you append your itab which will most likely disrupt the sorting:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;...
APPEND t_split.  " Still a sorted itab???
CLEAR t_split.
ELSE.
IF t_split-zwstdt = t_zwplccrimsr_hash-zwstdt AND
t_split-zweddt = t_zwplccrimsr_hash-zweddt AND
t_split-xloek = ' '.
DELETE t_split INDEX v_indx.  " should not disrupt sorting
ELSE..
...&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thus, either you sort your itab within the loop before the BINARY SEARCH or you collect the entries into an additional itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;  Uwe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Apr 2007 19:37:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-binary-search/m-p/2205395#M471630</guid>
      <dc:creator>uwe_schieferstein</dc:creator>
      <dc:date>2007-04-25T19:37:38Z</dc:date>
    </item>
    <item>
      <title>Re: read table binary search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-binary-search/m-p/2205396#M471631</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If internal table is of type standard then remove BINARY SEARCH option, it will work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amey&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Apr 2007 19:41:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-binary-search/m-p/2205396#M471631</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-04-25T19:41:38Z</dc:date>
    </item>
    <item>
      <title>Re: read table binary search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-binary-search/m-p/2205397#M471632</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Uwe is correct, please move the sort statement inside the loop then your binary search will work. But this may result performance issue if your internal table is too large (&amp;gt; million) sorting in a loop. You can also do as Amey suggested which is to remove BINARY SEARCH but if your internal table has too many records, it will result in a performance issue.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Apr 2007 19:45:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-binary-search/m-p/2205397#M471632</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-04-25T19:45:00Z</dc:date>
    </item>
    <item>
      <title>Re: read table binary search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-binary-search/m-p/2205398#M471633</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Internal table contains 1,65,000 records .If i remove Binary search is that causes any problem?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Apr 2007 20:17:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-binary-search/m-p/2205398#M471633</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-04-25T20:17:58Z</dc:date>
    </item>
    <item>
      <title>Re: read table binary search</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-binary-search/m-p/2205399#M471634</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Priya&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you need to add new entries to T_SPLIT within your loop then you could define this itab as &amp;lt;b&amp;gt;SORTED TABLE WITH UNIQUE KEY&amp;lt;/b&amp;gt; &amp;lt;i&amp;gt;matnr zwatctgp &amp;lt;/i&amp;gt;(I assume that this is possible. This means the itab cannot have duplicate entries for matnr zwatctgp ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;"SORT t_split BY matnr zwatctgp.  " obsolete if already SORTED TABLE
LOOP AT t_zwplccrimsr_hash.
READ TABLE t_split 
          WITH TABLE KEY matnr = t_zwplccrimsr_hash-matnr
                                zwatctgp = t_zwplccrimsr_hash-zwatctgp.

v_indx = sy-tabix .
IF sy-subrc &amp;lt;&amp;gt; 0.
MOVE-CORRESPONDING t_zwplccrimsr_hash TO t_split.
t_split-xloek = 'X'.
"APPEND t_split.
INSERT t_split INTO TABLE t_split.
CLEAR t_split.
ELSE.
IF t_split-zwstdt = t_zwplccrimsr_hash-zwstdt AND
t_split-zweddt = t_zwplccrimsr_hash-zweddt AND
t_split-xloek = ' '.
DELETE t_split INDEX v_indx .
ELSE.
t_split-zwcrus = t_zwplccrimsr_hash-zwcrus. "V001
t_split-zwcrdt = t_zwplccrimsr_hash-zwcrdt.
t_split-zwcrtm = t_zwplccrimsr_hash-zwcrtm.
t_split-zwchus = 'CREST'.
t_split-zwchdt = sy-datum.
t_split-zwchtm = sy-uzeit.

MODIFY t_split INDEX v_indx.
...&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;  Uwe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Apr 2007 21:36:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-binary-search/m-p/2205399#M471634</guid>
      <dc:creator>uwe_schieferstein</dc:creator>
      <dc:date>2007-04-25T21:36:43Z</dc:date>
    </item>
  </channel>
</rss>

