<?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: ABAP 7.4 (read table) in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-7-4-read-table/m-p/12094836#M1972269</link>
    <description>&lt;P&gt;You cannot use the BINARY SEARCH addition with the new expression. Even if you could, you should not. Use a sorted table type, so the lookup of records will always be accessed via binary search algorithm implicitly.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA: lt_ekko TYPE SORTED TABLE OF ekko WITH UNIQUE KEY ebeln.&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 26 Nov 2019 07:42:01 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2019-11-26T07:42:01Z</dc:date>
    <item>
      <title>ABAP 7.4 (read table)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-7-4-read-table/m-p/12094835#M1972268</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;TYPES: BEGIN OF ty_final,
         ebeln TYPE ekko-ebeln,
         bukrs TYPE ekko-bukrs,
         ebelp TYPE ekpo-ebelp,
       END OF ty_final.

DATA: lt_final TYPE TABLE OF ty_final,
      ls_final TYPE ty_final.

SELECT ebeln, bukrs FROM ekko INTO TABLE @DATA(lt_ekko) UP TO 5 ROWS.

IF sy-subrc = 0.
  SELECT ebeln, ebelp FROM ekpo INTO TABLE @DATA(lt_ekpo)
     FOR ALL ENTRIES IN @lt_ekko WHERE ebeln = @lt_ekko-ebeln.
ENDIF.

SORT: lt_ekko BY ebeln,lt_ekpo BY ebeln.

LOOP AT lt_ekpo INTO DATA(ls_ekpo).
  ls_final-ebeln = ls_ekpo-ebeln.
  ls_final-ebelp = ls_ekpo-ebelp.

*  READ TABLE lt_ekko INTO DATA(ls_ekko) WITH KEY ebeln = ls_ekpo-ebeln BINARY SEARCH.

data(ls_ekko) = lt_ekko[ ebeln = ls_ekpo-ebeln ]."Binary search not working

  IF sy-subrc = 0.
    ls_final-bukrs = ls_ekko-bukrs.
  ENDIF.
  APPEND ls_final TO lt_final.

ENDLOOP.

cl_demo_output=&amp;gt;display( lt_final ).
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;Hi, &lt;/P&gt;
  &lt;P&gt; How to use binary search in read table for the new ABAP 7.4&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2019 07:26:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-7-4-read-table/m-p/12094835#M1972268</guid>
      <dc:creator>DKanna</dc:creator>
      <dc:date>2019-11-26T07:26:58Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP 7.4 (read table)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-7-4-read-table/m-p/12094836#M1972269</link>
      <description>&lt;P&gt;You cannot use the BINARY SEARCH addition with the new expression. Even if you could, you should not. Use a sorted table type, so the lookup of records will always be accessed via binary search algorithm implicitly.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA: lt_ekko TYPE SORTED TABLE OF ekko WITH UNIQUE KEY ebeln.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Nov 2019 07:42:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-7-4-read-table/m-p/12094836#M1972269</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-11-26T07:42:01Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP 7.4 (read table)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-7-4-read-table/m-p/12094837#M1972270</link>
      <description>&lt;P&gt;You need to declare the internal table as sorted table. &lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2019 08:12:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-7-4-read-table/m-p/12094837#M1972270</guid>
      <dc:creator>FredericGirod</dc:creator>
      <dc:date>2019-11-26T08:12:12Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP 7.4 (read table)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-7-4-read-table/m-p/12094838#M1972271</link>
      <description>&lt;P&gt;Hi, I don´t know what is the error I execute the next code and work fine.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TYPES: BEGIN OF ty_final,
  ebeln TYPE ekko-ebeln,
  bukrs TYPE ekko-bukrs,
  ebelp TYPE ekpo-ebelp,
END OF ty_final.

DATA: lt_final TYPE TABLE OF ty_final,
      ls_final TYPE ty_final.

SELECT ebeln, bukrs FROM ekko INTO TABLE @DATA(lt_ekko) UP TO 5 ROWS.

IF sy-subrc = 0.
  SELECT ebeln, ebelp FROM ekpo INTO TABLE @DATA(lt_ekpo)
        FOR ALL ENTRIES IN @lt_ekko WHERE ebeln = @lt_ekko-ebeln.
ENDIF.

SORT: lt_ekko BY ebeln,lt_ekpo BY ebeln.


LOOP AT lt_ekpo INTO DATA(ls_ekpo).
  ls_final-ebeln = ls_ekpo-ebeln.
  ls_final-ebelp = ls_ekpo-ebelp.
  READ TABLE lt_ekko INTO DATA(ls_ekko) WITH KEY ebeln = ls_ekpo-ebeln BINARY SEARCH.

  IF sy-subrc = 0.
    ls_final-bukrs = ls_ekko-bukrs.
  ENDIF.
  APPEND ls_final TO lt_final.
  CLEAR ls_ekko.
ENDLOOP.

cl_demo_output=&amp;gt;display( lt_final ).
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1750729-lt-final.jpg" /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 02:14:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-7-4-read-table/m-p/12094838#M1972271</guid>
      <dc:creator>mlizcano1</dc:creator>
      <dc:date>2019-11-27T02:14:12Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP 7.4 (read table)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-7-4-read-table/m-p/12094839#M1972272</link>
      <description>&lt;P&gt;NB: the answer is ambiguous ("cannot use [the binary search] with the new expression" (&lt;A href="https://help.sap.com/doc/abapdocu_753_index_htm/7.53/en-US/index.htm?file=abentable_expressions.htm"&gt;table expression&lt;/A&gt;)) because in fact when the table is of type SORTED a table expression &lt;STRONG&gt;uses the &lt;A href="https://en.wikipedia.org/wiki/Binary_search_algorithm"&gt;binary search algorithm&lt;/A&gt; implicitly &lt;/STRONG&gt;(if the components match the key), so you mean that the two words "BINARY SEARCH" cannot be used explicitly in a table expression as they are with READ TABLE.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 03:17:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-7-4-read-table/m-p/12094839#M1972272</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2019-11-27T03:17:34Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP 7.4 (read table)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-7-4-read-table/m-p/12094840#M1972273</link>
      <description>&lt;P&gt;  &lt;SPAN class="mention-scrubbed"&gt;sandra.rossi&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;Thanks, reading the answer after a day was in fact ambiguous. I was trying to say that whenever you have to type BINARY SEARCH it is a certain thing that you are using the wrong table type. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 13:23:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-7-4-read-table/m-p/12094840#M1972273</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-11-27T13:23:27Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP 7.4 (read table)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-7-4-read-table/m-p/12094841#M1972274</link>
      <description>&lt;P&gt;Hi  &lt;SPAN class="mention-scrubbed"&gt;dhanushkanna&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;About your statement:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data(ls_ekko) = lt_ekko[ ebeln = ls_ekpo-ebeln ]."Binary search not working&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Beware with this type of table read... Sometimes when this internal table was initial or the line don't exists you'll get a dump...&lt;/P&gt;&lt;P&gt;Use Try Catch or this statement: DATA(ls_ekko) = VALUE #( lt_ekko[ ebeln = ls_ekpo-ebeln ] OPTIONAL ).&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;U&gt;&lt;/U&gt;&lt;SUB&gt;&lt;/SUB&gt;&lt;SUP&gt;&lt;/SUP&gt;&lt;DEL&gt;&lt;/DEL&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 14:21:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-7-4-read-table/m-p/12094841#M1972274</guid>
      <dc:creator>raphael_almeida</dc:creator>
      <dc:date>2019-11-27T14:21:22Z</dc:date>
    </item>
  </channel>
</rss>

