<?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 syntax for If condition within loop. in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-7-4-syntax-for-if-condition-within-loop/m-p/12311479#M1990842</link>
    <description>&lt;P&gt;Why isn't it possible with LE / &amp;lt;= ? (there's only an issue with EXIT for which the only workaround I know is to use a THROW exception):&lt;/P&gt;&lt;P&gt;I didn't test it, something like that:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TRY.
  DATA(lv_value) = REDUCE #( 
      INIT v TYPE ... 
           exit TYPE i
      FOR ... WHERE ( ... erdat &amp;lt;= sy-datum ... )
      NEXT v    = ...
           exit = COND #( WHEN v IS NOT INITIAL THEN THROW lx_stop ) )
CATCH lx_stop.
  " Stop
ENDTRY.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;of course that's a stupid code &lt;span class="lia-unicode-emoji" title=":face_with_tongue:"&gt;😛&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 03 Mar 2021 08:02:03 GMT</pubDate>
    <dc:creator>Sandra_Rossi</dc:creator>
    <dc:date>2021-03-03T08:02:03Z</dc:date>
    <item>
      <title>ABAP 7.4 syntax for If condition within loop.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-7-4-syntax-for-if-condition-within-loop/m-p/12311477#M1990840</link>
      <description>&lt;P&gt;Hello Experts,&lt;/P&gt;
  &lt;P&gt;Please help me how i can write below type of Loop AT statement as per 7.4 syntax.&lt;/P&gt;
  &lt;P&gt;Loop at lt_items into data(ls_items) where matnr = hzd456 and erdat le sy-datum .&lt;/P&gt;
  &lt;P&gt;if ls_items-sequence = 1.&lt;/P&gt;
  &lt;P&gt;lv_found = 'X'.&lt;/P&gt;
  &lt;P&gt;exit.&lt;/P&gt;
  &lt;P&gt;else.&lt;/P&gt;
  &lt;P&gt;clear : ls_items.&lt;/P&gt;
  &lt;P&gt;Endif.&lt;/P&gt;
  &lt;P&gt;endloop.&lt;/P&gt;
  &lt;P&gt;lv_value = ls_items-value.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Mar 2021 04:55:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-7-4-syntax-for-if-condition-within-loop/m-p/12311477#M1990840</guid>
      <dc:creator>former_member444368</dc:creator>
      <dc:date>2021-03-03T04:55:59Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP 7.4 syntax for If condition within loop.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-7-4-syntax-for-if-condition-within-loop/m-p/12311478#M1990841</link>
      <description>&lt;P&gt;As you have a LE condition no usage of a table expression is possible. So an adapted loop is a good option from my point of view (consider to use e.g. a sorted table when you have a lot of data in the internal table):&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT lt_items REFERENCE INTO DATA(lr_item)
WHERE matnr = 'hzd456'
  AND erdat le sy-datum
  AND sequence = 1.
  
  lv_value = lr_item-&amp;gt;value.
  EXIT.

ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Of course you could write something like following, but I see not real advantage in that:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA(lt_filtered_items) = FILTER #( lt_items 
  WHERE matnr = 'hzd456' AND erdat le sy-datum AND sequence = 1 ).

TRY.
  lv_value = lt_filtered_items[ 1 ]-value.
CATCH cx_sy_itab_line_not_found.
  " exception handling
ENDTRY.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 03 Mar 2021 06:20:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-7-4-syntax-for-if-condition-within-loop/m-p/12311478#M1990841</guid>
      <dc:creator>pfefferf</dc:creator>
      <dc:date>2021-03-03T06:20:30Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP 7.4 syntax for If condition within loop.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-7-4-syntax-for-if-condition-within-loop/m-p/12311479#M1990842</link>
      <description>&lt;P&gt;Why isn't it possible with LE / &amp;lt;= ? (there's only an issue with EXIT for which the only workaround I know is to use a THROW exception):&lt;/P&gt;&lt;P&gt;I didn't test it, something like that:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TRY.
  DATA(lv_value) = REDUCE #( 
      INIT v TYPE ... 
           exit TYPE i
      FOR ... WHERE ( ... erdat &amp;lt;= sy-datum ... )
      NEXT v    = ...
           exit = COND #( WHEN v IS NOT INITIAL THEN THROW lx_stop ) )
CATCH lx_stop.
  " Stop
ENDTRY.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;of course that's a stupid code &lt;span class="lia-unicode-emoji" title=":face_with_tongue:"&gt;😛&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Mar 2021 08:02:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-7-4-syntax-for-if-condition-within-loop/m-p/12311479#M1990842</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2021-03-03T08:02:03Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP 7.4 syntax for If condition within loop.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-7-4-syntax-for-if-condition-within-loop/m-p/12311480#M1990843</link>
      <description>&lt;P&gt;Sure, with a REDUCE expression it is possible - not really readable on a first glimpse, but it works. &lt;/P&gt;&lt;P&gt;I talked about table expressions.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Mar 2021 08:04:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-7-4-syntax-for-if-condition-within-loop/m-p/12311480#M1990843</guid>
      <dc:creator>pfefferf</dc:creator>
      <dc:date>2021-03-03T08:04:40Z</dc:date>
    </item>
  </channel>
</rss>

