<?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: Deep for statment in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/deep-for-statment/m-p/12207475#M1982452</link>
    <description>&lt;P&gt;Here, so people don't have to download a .txt file. Please, if possible, try to use the 'CODE' button in the future.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TYPES ttt_wa1 TYPE STANDARD TABLE OF ty_wa1 WITH EMPTY KEY.
TYPES ttt_wa2 TYPE STANDARD TABLE OF ty_wa2 WITH EMPTY KEY.


DATA:itab2 TYPE TABLE OF ty_wa1.


DATA(itab1) = VALUE ttt_wa1( ( field1 = 1 field2 = 2 )
                             ( field1 = 1 field2 = 2 ) ).

DATA(target1) = VALUE ttt_wa2( FOR lwa_source IN itab1 ( CORRESPONDING #( lwa_source ) ) ).
 
TYPES: BEGIN OF ty_final,
         ebeln TYPE ebeln,
         ebelp TYPE ebelp,
         lifnr TYPE lifnr,
         matnr TYPE matnr,
         maktx TYPE maktx,
         werks TYPE werks_d,
         name1 TYPE name1,
       END OF ty_final,
       ty_t_final TYPE STANDARD TABLE OF ty_final WITH DEFAULT KEY.

START-OF-SELECTION.
  SELECT * FROM ekko
   UP TO 10 ROWS
    INTO TABLE @DATA(lt_ekko).
  IF sy-subrc = 0.
    SELECT * FROM ekpo
     INTO TABLE @DATA(lt_ekpo)
      FOR ALL ENTRIES IN @lt_ekko
       WHERE ebeln = @lt_ekko-ebeln.
    IF sy-subrc = 0.
      SELECT * FROM makt INTO TABLE @DATA(lt_makt)
       FOR ALL ENTRIES IN @lt_ekpo
        WHERE matnr = @lt_ekpo-matnr
        AND spras = @sy-langu.


      SELECT * FROM t001w INTO TABLE @DATA(lt_t001w)
         FOR ALL ENTRIES IN @lt_ekpo
          WHERE werks = @lt_ekpo-werks.


*Sort the tables with proper key
      SORT: lt_ekko  BY ebeln,
            lt_ekpo  BY ebeln ebelp,
            lt_makt  BY matnr,
            lt_t001w BY werks.

*Populate the final table based on the data from EKKO,EKPO,MAKT and T001W using "Parallel Cursor"
      DATA(lt_final) = VALUE ty_t_final( FOR ls_ekpo IN lt_ekpo
                       FOR ls_ekko IN lt_ekko FROM line_index( lt_ekko[ ebeln = ls_ekpo-ebeln ] )
                       WHERE ( ebeln = ls_ekpo-ebeln )
                       FOR ls_makt IN lt_makt FROM line_index( lt_makt[ matnr = ls_ekpo-matnr ] )
                       WHERE ( matnr = ls_ekpo-matnr )
                       FOR ls_t001w IN lt_t001w FROM line_index( lt_t001w[ werks = ls_ekpo-werks ] )
                       WHERE ( werks = ls_ekpo-werks )
                       LET ls_final = VALUE ty_final(
                            lifnr = ls_ekko-lifnr
                            maktx = ls_makt-maktx
                            name1 = ls_t001w-name1 )
                       IN ( CORRESPONDING #( BASE ( ls_final ) ls_ekpo ) ) ).&amp;lt;br&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 08 May 2020 16:11:21 GMT</pubDate>
    <dc:creator>wridgeu</dc:creator>
    <dc:date>2020-05-08T16:11:21Z</dc:date>
    <item>
      <title>Deep for statment</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/deep-for-statment/m-p/12207470#M1982447</link>
      <description>&lt;P&gt;Hi All ,&lt;/P&gt;
  &lt;P&gt;&lt;BR /&gt;I am testing below example found in web . &lt;/P&gt;
  &lt;P&gt; I am getting no result into lt_final table as there are no values in lt_makt table . Can somebody suggest that how to validate tables are initial or not . &lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;DATA(lt_final) = VALUE ty_t_final( FOR ls_ekpo IN lt_ekpo&lt;/STRONG&gt;&lt;BR /&gt; &lt;STRONG&gt;FOR ls_ekko IN lt_ekko FROM line_index( lt_ekko[ ebeln = ls_ekpo-ebeln ] )&lt;BR /&gt; WHERE ( ebeln = ls_ekpo-ebeln )&lt;BR /&gt; FOR ls_makt IN lt_makt FROM line_index( lt_makt[ matnr = ls_ekpo-matnr ] )&lt;BR /&gt; WHERE ( matnr = ls_ekpo-matnr )&lt;BR /&gt; FOR ls_t001w IN lt_t001w FROM line_index( lt_t001w[ werks = ls_ekpo-werks ] )&lt;BR /&gt; WHERE ( werks = ls_ekpo-werks )&lt;BR /&gt; LET ls_final = VALUE ty_final(&lt;BR /&gt; lifnr = ls_ekko-lifnr&lt;BR /&gt; maktx = ls_makt-maktx&lt;BR /&gt; name1 = ls_t001w-name1 )&lt;BR /&gt; IN ( CORRESPONDING #( BASE ( ls_final ) ls_ekpo ) ) ).&lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt;Regards,&lt;/P&gt;
  &lt;P&gt;Srikanth&lt;/P&gt;</description>
      <pubDate>Fri, 08 May 2020 13:13:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/deep-for-statment/m-p/12207470#M1982447</guid>
      <dc:creator>srikanth_srikanth12</dc:creator>
      <dc:date>2020-05-08T13:13:32Z</dc:date>
    </item>
    <item>
      <title>Re: Deep for statment</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/deep-for-statment/m-p/12207471#M1982448</link>
      <description>&lt;P&gt;Can you be more specific? When or where do you want to check for table with no data and when or where for table with data? And why do you want to do that? Is there a dump? Do you want to skip some statements?&lt;/P&gt;</description>
      <pubDate>Fri, 08 May 2020 13:24:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/deep-for-statment/m-p/12207471#M1982448</guid>
      <dc:creator>michael_piesche</dc:creator>
      <dc:date>2020-05-08T13:24:35Z</dc:date>
    </item>
    <item>
      <title>Re: Deep for statment</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/deep-for-statment/m-p/12207472#M1982449</link>
      <description>&lt;P&gt;Please use the CODE button to format your code so that it's shown in a more user-friendly format (colorized).&lt;/P&gt;</description>
      <pubDate>Fri, 08 May 2020 13:57:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/deep-for-statment/m-p/12207472#M1982449</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2020-05-08T13:57:57Z</dc:date>
    </item>
    <item>
      <title>Re: Deep for statment</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/deep-for-statment/m-p/12207473#M1982450</link>
      <description>&lt;P&gt;Performance hint: it seems that you tried to implement so-called "parallel cursor" using nested table iterations, but that's slower than doing it with classic ABAP because you cannot exit the loops at "key breaks". This is exactly this kind of situation where so-called "new ABAP" should not be used.&lt;/P&gt;</description>
      <pubDate>Fri, 08 May 2020 14:05:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/deep-for-statment/m-p/12207473#M1982450</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2020-05-08T14:05:45Z</dc:date>
    </item>
    <item>
      <title>Re: Deep for statment</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/deep-for-statment/m-p/12207474#M1982451</link>
      <description>&lt;P&gt;Hi All ,&lt;/P&gt;&lt;P&gt;Thank you all for reply so quickly ..i attached the code in notepad .&lt;/P&gt;&lt;P&gt;Here my question is &lt;/P&gt;&lt;P&gt; -&amp;gt; lt_final table is not filling becuase in my system lt_makt is Initial.&lt;/P&gt;&lt;P&gt;    I am thinking that lt_fina tab is not filling because
lt_makt is initial . is this correct ?.     &lt;/P&gt;&lt;P&gt;     Is there any way to check
lt_makt is not initial or not &lt;STRONG&gt;.&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 08 May 2020 15:40:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/deep-for-statment/m-p/12207474#M1982451</guid>
      <dc:creator>srikanth_srikanth12</dc:creator>
      <dc:date>2020-05-08T15:40:15Z</dc:date>
    </item>
    <item>
      <title>Re: Deep for statment</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/deep-for-statment/m-p/12207475#M1982452</link>
      <description>&lt;P&gt;Here, so people don't have to download a .txt file. Please, if possible, try to use the 'CODE' button in the future.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TYPES ttt_wa1 TYPE STANDARD TABLE OF ty_wa1 WITH EMPTY KEY.
TYPES ttt_wa2 TYPE STANDARD TABLE OF ty_wa2 WITH EMPTY KEY.


DATA:itab2 TYPE TABLE OF ty_wa1.


DATA(itab1) = VALUE ttt_wa1( ( field1 = 1 field2 = 2 )
                             ( field1 = 1 field2 = 2 ) ).

DATA(target1) = VALUE ttt_wa2( FOR lwa_source IN itab1 ( CORRESPONDING #( lwa_source ) ) ).
 
TYPES: BEGIN OF ty_final,
         ebeln TYPE ebeln,
         ebelp TYPE ebelp,
         lifnr TYPE lifnr,
         matnr TYPE matnr,
         maktx TYPE maktx,
         werks TYPE werks_d,
         name1 TYPE name1,
       END OF ty_final,
       ty_t_final TYPE STANDARD TABLE OF ty_final WITH DEFAULT KEY.

START-OF-SELECTION.
  SELECT * FROM ekko
   UP TO 10 ROWS
    INTO TABLE @DATA(lt_ekko).
  IF sy-subrc = 0.
    SELECT * FROM ekpo
     INTO TABLE @DATA(lt_ekpo)
      FOR ALL ENTRIES IN @lt_ekko
       WHERE ebeln = @lt_ekko-ebeln.
    IF sy-subrc = 0.
      SELECT * FROM makt INTO TABLE @DATA(lt_makt)
       FOR ALL ENTRIES IN @lt_ekpo
        WHERE matnr = @lt_ekpo-matnr
        AND spras = @sy-langu.


      SELECT * FROM t001w INTO TABLE @DATA(lt_t001w)
         FOR ALL ENTRIES IN @lt_ekpo
          WHERE werks = @lt_ekpo-werks.


*Sort the tables with proper key
      SORT: lt_ekko  BY ebeln,
            lt_ekpo  BY ebeln ebelp,
            lt_makt  BY matnr,
            lt_t001w BY werks.

*Populate the final table based on the data from EKKO,EKPO,MAKT and T001W using "Parallel Cursor"
      DATA(lt_final) = VALUE ty_t_final( FOR ls_ekpo IN lt_ekpo
                       FOR ls_ekko IN lt_ekko FROM line_index( lt_ekko[ ebeln = ls_ekpo-ebeln ] )
                       WHERE ( ebeln = ls_ekpo-ebeln )
                       FOR ls_makt IN lt_makt FROM line_index( lt_makt[ matnr = ls_ekpo-matnr ] )
                       WHERE ( matnr = ls_ekpo-matnr )
                       FOR ls_t001w IN lt_t001w FROM line_index( lt_t001w[ werks = ls_ekpo-werks ] )
                       WHERE ( werks = ls_ekpo-werks )
                       LET ls_final = VALUE ty_final(
                            lifnr = ls_ekko-lifnr
                            maktx = ls_makt-maktx
                            name1 = ls_t001w-name1 )
                       IN ( CORRESPONDING #( BASE ( ls_final ) ls_ekpo ) ) ).&amp;lt;br&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 May 2020 16:11:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/deep-for-statment/m-p/12207475#M1982452</guid>
      <dc:creator>wridgeu</dc:creator>
      <dc:date>2020-05-08T16:11:21Z</dc:date>
    </item>
    <item>
      <title>Re: Deep for statment</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/deep-for-statment/m-p/12207476#M1982453</link>
      <description>&lt;P&gt;&lt;SPAN class="mention-scrubbed"&gt;marcobeier&lt;/SPAN&gt; Thank you&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mention-scrubbed"&gt;srikanth.srikanth12&lt;/SPAN&gt; You're correct, the loops are nested so if one of the internal tables is empty, the final result is empty. Of course, you can define conditions inside the constructor expression, but that will make the expression completely unmaintainable. And as I already said, you are just writing "bad" code here, don't use table iterations for implementing "parallel cursor".&lt;/P&gt;</description>
      <pubDate>Fri, 08 May 2020 16:22:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/deep-for-statment/m-p/12207476#M1982453</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2020-05-08T16:22:51Z</dc:date>
    </item>
    <item>
      <title>Re: Deep for statment</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/deep-for-statment/m-p/12207477#M1982454</link>
      <description>&lt;P&gt;Thank you all. &lt;/P&gt;&lt;P&gt; thank you so much for suggestion . your comments are really help full .&lt;/P&gt;&lt;P&gt;is there any possibilty of share best example for parallel cursor with new 7.4 or 7.5 features .&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thank you so much again.&lt;/P&gt;&lt;P&gt;SrikanthSuvarna.&lt;/P&gt;</description>
      <pubDate>Sat, 09 May 2020 10:17:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/deep-for-statment/m-p/12207477#M1982454</guid>
      <dc:creator>srikanth_srikanth12</dc:creator>
      <dc:date>2020-05-09T10:17:07Z</dc:date>
    </item>
    <item>
      <title>Re: Deep for statment</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/deep-for-statment/m-p/12207478#M1982455</link>
      <description>&lt;P&gt;You ask:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;is there any possibility of share best example for parallel cursor with new 7.4 or 7.5 features .&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;No, it's bad practice, but maybe you didn't understand my first answer, so sorry to repeat myself: it seems that you tried to implement so-called "parallel cursor" using nested table iterations, but &lt;B&gt;that's slower than doing it with classic ABAP because you cannot exit the loops at "key breaks"&lt;/B&gt;. This is exactly this kind of situation where so-called "new ABAP" should not be used.&lt;/P&gt;&lt;P&gt;Another example where "new ABAP" should not be used, is to update existing variables. Constructor expressions are for constructing, not updating (of course, you could re-construct by duplicating and altering the original value, but you understand that it's slower and so should not be used, especially for huge internal tables).&lt;/P&gt;&lt;P&gt;I hope you understand what I mean.&lt;/P&gt;&lt;P&gt;NB: Please use the COMMENT button for comments, questions, adding details, etc., ANSWER is only to propose a solution, dixit SAP text at the right of the answer area.&lt;/P&gt;</description>
      <pubDate>Sat, 09 May 2020 15:42:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/deep-for-statment/m-p/12207478#M1982455</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2020-05-09T15:42:05Z</dc:date>
    </item>
  </channel>
</rss>

