<?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: Problems with constructor expression in case statement in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-problems-with-constructor-expression-in-case-statement/m-p/544413#M20409</link>
    <description>&lt;P&gt;I am working on 7.40 SP16. It's true that there is only a warning in your code, but as soon as you put the code inside a method, the warning becomes an error:&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;class lcl_a definition.
  public section.
    methods main.
endclass.

class lcl_a implementation.
  method main.
    case value i( ).
      when 1.
    endcase.
    case reduce i( init x = 0
                   for i = 1 until i &amp;gt; 1
                   next x = 1 ).
      when 1.
    endcase.
    data itab type table of i.
    case reduce i( init x = 0
                   for wa in itab
                   next x = 1 ).
      when 1.
    endcase.
  endmethod.
endclass.

&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 05 Dec 2017 10:49:49 GMT</pubDate>
    <dc:creator>jrgkraus</dc:creator>
    <dc:date>2017-12-05T10:49:49Z</dc:date>
    <item>
      <title>ABAP: Problems with constructor expression in case statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-problems-with-constructor-expression-in-case-statement/m-p/544411#M20407</link>
      <description>&lt;P&gt;The following coding produces a syntax error "WHEN must be the first statement after a CASE statement.":&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;   case reduce i( init count = 0
      for s_mat in mt_materials where ( lead = abap_true )
      next count = count + 1 ).
      when 0.
        raise exception type lcx_no_lead_mat.
      when 1.
        " OK.
      when others.
        raise exception type lcx_multiple_lead.
    endcase.

&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;Whilst this version passes without problems:&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;    data(lv_count) = reduce i( init count = 0
      for s_mat in mt_materials where ( lead = abap_true )
        next count = count + 1 ).
    case lv_count.
      for s_mat in mt_materials where ( lead = abap_true )
      next count = count + 1 ).
      when 0.
        raise exception type lcx_no_lead_mat.
      when 1.
        " OK.
      when others.
        raise exception type lcx_multiple_lead.
    endcase.

&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;ABAP docu says that the operand of a case statement is a general expression position, so I should be able to use reduce in this place. Where am i doing wrong?&lt;/P&gt;</description>
      <pubDate>Tue, 05 Dec 2017 08:35:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-problems-with-constructor-expression-in-case-statement/m-p/544411#M20407</guid>
      <dc:creator>jrgkraus</dc:creator>
      <dc:date>2017-12-05T08:35:18Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP: Problems with constructor expression in case statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-problems-with-constructor-expression-in-case-statement/m-p/544412#M20408</link>
      <description>&lt;P&gt;What release are you working on?&lt;/P&gt;
  &lt;P&gt; The following gives a syntax warning for the last CASE down to 7.40, SP08, but not an error.&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;CASE VALUE i( ).
  WHEN 1.
ENDCASE.

CASE REDUCE i( INIT x = 0
               FOR i = 1 UNTIL i &amp;gt; 1
               NEXT x = 1 ).
  WHEN 1.
ENDCASE.

DATA itab TYPE TABLE OF i.
CASE REDUCE i( INIT x = 0
               FOR wa IN itab
               NEXT x = 1 ).
  WHEN 1.
ENDCASE.
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;The warning is strange, -&amp;gt;development&lt;/P&gt;</description>
      <pubDate>Tue, 05 Dec 2017 09:06:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-problems-with-constructor-expression-in-case-statement/m-p/544412#M20408</guid>
      <dc:creator>retired_member</dc:creator>
      <dc:date>2017-12-05T09:06:58Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP: Problems with constructor expression in case statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-problems-with-constructor-expression-in-case-statement/m-p/544413#M20409</link>
      <description>&lt;P&gt;I am working on 7.40 SP16. It's true that there is only a warning in your code, but as soon as you put the code inside a method, the warning becomes an error:&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;class lcl_a definition.
  public section.
    methods main.
endclass.

class lcl_a implementation.
  method main.
    case value i( ).
      when 1.
    endcase.
    case reduce i( init x = 0
                   for i = 1 until i &amp;gt; 1
                   next x = 1 ).
      when 1.
    endcase.
    data itab type table of i.
    case reduce i( init x = 0
                   for wa in itab
                   next x = 1 ).
      when 1.
    endcase.
  endmethod.
endclass.

&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Dec 2017 10:49:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-problems-with-constructor-expression-in-case-statement/m-p/544413#M20409</guid>
      <dc:creator>jrgkraus</dc:creator>
      <dc:date>2017-12-05T10:49:49Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP: Problems with constructor expression in case statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-problems-with-constructor-expression-in-case-statement/m-p/544414#M20410</link>
      <description>&lt;P&gt;Oh wow -&amp;gt; the bug is even more severe &lt;/P&gt;</description>
      <pubDate>Tue, 05 Dec 2017 10:52:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-problems-with-constructor-expression-in-case-statement/m-p/544414#M20410</guid>
      <dc:creator>retired_member</dc:creator>
      <dc:date>2017-12-05T10:52:23Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP: Problems with constructor expression in case statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-problems-with-constructor-expression-in-case-statement/m-p/544415#M20411</link>
      <description>&lt;P&gt;Corrected in an upcoming release (but no patch).&lt;/P&gt;
  &lt;P&gt;Thanks for notifying!&lt;/P&gt;</description>
      <pubDate>Tue, 05 Dec 2017 17:37:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-problems-with-constructor-expression-in-case-statement/m-p/544415#M20411</guid>
      <dc:creator>retired_member</dc:creator>
      <dc:date>2017-12-05T17:37:51Z</dc:date>
    </item>
  </channel>
</rss>

