<?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: Rewrite the LOOP through FOR or REDUCE in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/rewrite-the-loop-through-for-or-reduce/m-p/11923311#M1964097</link>
    <description>&lt;P&gt;idealy you could do like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA(lt_filtered_customers1) = VALUE tt_customers( FOR ls_customer1 IN t_customres
                                                   ( COND #( WHEN NOT line_exists( t_routes[ route = ls_customer1-route ] ) THEN ls_customer1 ) ) ).&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 09 May 2019 01:23:40 GMT</pubDate>
    <dc:creator>DoanManhQuynh</dc:creator>
    <dc:date>2019-05-09T01:23:40Z</dc:date>
    <item>
      <title>Rewrite the LOOP through FOR or REDUCE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/rewrite-the-loop-through-for-or-reduce/m-p/11923310#M1964096</link>
      <description>&lt;P&gt;Hi all &lt;/P&gt;
  &lt;P&gt;Is it possible to rewrite this code snippet with FOR or REDUCE? &lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;LOOP AT t_customres REFERENCE INTO DATA(ls_customer).
 IF line_exists( t_routes[ route = ls_customer-&amp;gt;route ] ) .
 CONTINUE.
 ENDIF.
 INSERT ls_customer-&amp;gt;* INTO TABLE lt_filtered_customers.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;The whole program: &lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;TYPES:
 BEGIN OF ty_customer,
 customer TYPE char10,
 name TYPE char30,
 city TYPE char30,
 route TYPE char10,
 END OF ty_customer.
TYPES: tt_customers TYPE SORTED TABLE OF ty_customer
 WITH UNIQUE KEY customer.
TYPES:
 BEGIN OF ty_routes,
 route TYPE char10,
 name TYPE char40,
 END OF ty_routes.
TYPES: tt_routes TYPE SORTED TABLE OF ty_routes
 WITH UNIQUE KEY route.
DATA(t_customres) =
 VALUE tt_customers(
 ( customer = 'C0001' name = 'Test Customer 1' city = 'NY' route = 'R0001' )
 ( customer = 'C0002' name = 'Customer 2' city = 'LA' route = 'R0003' )
 ( customer = 'C0003' name = 'Good Customer 3' city = 'DFW' route = 'R0001' )
 ( customer = 'C0004' name = 'Best Customer 4' city = 'CH' route = 'R0003' )
 ( customer = 'C0005' name = 'Best Customer 4' city = 'CH' route = 'R0005' )
 ( customer = 'C0006' name = 'Best Customer 4' city = 'CH' route = 'R0005' )
 ).
DATA(t_routes) =
 VALUE tt_routes(
 ( route = 'R0001' name = 'Route 1' )
 ( route = 'R0002' name = 'Route 2' )
 ( route = 'R0003' name = 'Route 3' )
 ).
DATA(lt_filtered_customers) = VALUE tt_customers( ).
LOOP AT t_customres REFERENCE INTO DATA(ls_customer).
 IF line_exists( t_routes[ route = ls_customer-&amp;gt;route ] ) .
 CONTINUE.
 ENDIF.
 INSERT ls_customer-&amp;gt;* INTO TABLE lt_filtered_customers.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2019 13:05:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/rewrite-the-loop-through-for-or-reduce/m-p/11923310#M1964096</guid>
      <dc:creator>friendlycoder</dc:creator>
      <dc:date>2019-05-08T13:05:03Z</dc:date>
    </item>
    <item>
      <title>Re: Rewrite the LOOP through FOR or REDUCE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/rewrite-the-loop-through-for-or-reduce/m-p/11923311#M1964097</link>
      <description>&lt;P&gt;idealy you could do like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA(lt_filtered_customers1) = VALUE tt_customers( FOR ls_customer1 IN t_customres
                                                   ( COND #( WHEN NOT line_exists( t_routes[ route = ls_customer1-route ] ) THEN ls_customer1 ) ) ).&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 May 2019 01:23:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/rewrite-the-loop-through-for-or-reduce/m-p/11923311#M1964097</guid>
      <dc:creator>DoanManhQuynh</dc:creator>
      <dc:date>2019-05-09T01:23:40Z</dc:date>
    </item>
  </channel>
</rss>

