<?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: LOOP AT GROUP BY external loop variable/field symbol in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-group-by-external-loop-variable-field-symbol/m-p/12679911#M2016887</link>
    <description>&lt;P&gt;easier and &lt;STRONG&gt;more legible&lt;/STRONG&gt; maybe, because I personally don't see a better alternative.&lt;/P&gt;</description>
    <pubDate>Wed, 01 Feb 2023 07:03:44 GMT</pubDate>
    <dc:creator>Sandra_Rossi</dc:creator>
    <dc:date>2023-02-01T07:03:44Z</dc:date>
    <item>
      <title>LOOP AT GROUP BY external loop variable/field symbol</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-group-by-external-loop-variable-field-symbol/m-p/12679908#M2016884</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;
  &lt;P&gt;A question which I need to raise in order to just clear up my ideas, since I am already achieving what I need using the powerful LOOP AT ... GROUP BY.&lt;/P&gt;
  &lt;P&gt;I have the following code:&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;      LOOP AT internal_table INTO DATA(record)
        GROUP BY ( criteria = record-somefield )
        ASSIGNING FIELD-SYMBOL(&amp;lt;group&amp;gt;).
            "some code here
        LOOP AT GROUP &amp;lt;group&amp;gt; ASSIGNING FIELD-SYMBOL(&amp;lt;group_member&amp;gt;).
           "other code: here we can modify the group member using &amp;lt;group_member&amp;gt;
        ENDLOOP.
      ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;I cannot understand the reason to declare the variable "record", in the external part of the loop: it stays initial for the whole time.&lt;/P&gt;
  &lt;P&gt;I checked several blogs and documentation, so I ask in case somebody knows.&lt;/P&gt;
  &lt;P&gt;Thanks a lot in advance for your precious help!&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2023 15:54:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-group-by-external-loop-variable-field-symbol/m-p/12679908#M2016884</guid>
      <dc:creator>AlbertoR</dc:creator>
      <dc:date>2023-01-31T15:54:30Z</dc:date>
    </item>
    <item>
      <title>Re: LOOP AT GROUP BY external loop variable/field symbol</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-group-by-external-loop-variable-field-symbol/m-p/12679909#M2016885</link>
      <description>&lt;P&gt;I hope SAP experts will answer that question.&lt;/P&gt;&lt;P&gt;I think it's because the old compiler has been reused or almost unchanged, so it's more or less &lt;A href="https://en.wikipedia.org/wiki/Source-to-source_compiler"&gt;transpiling&lt;/A&gt; to ABAP byte code via classic ABAP, it was probably easier to ask the developer to declare that intermediate variable.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2023 20:02:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-group-by-external-loop-variable-field-symbol/m-p/12679909#M2016885</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2023-01-31T20:02:59Z</dc:date>
    </item>
    <item>
      <title>Re: LOOP AT GROUP BY external loop variable/field symbol</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-group-by-external-loop-variable-field-symbol/m-p/12679910#M2016886</link>
      <description>&lt;P&gt;At least in &lt;A href="https://blogs.sap.com/2016/06/23/group-by-for-internal-tables-step-by-stepc/"&gt;representative binding&lt;/A&gt;, the variable "record" contains the first line of each group in the loop:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT internal_table INTO DATA(record) GROUP BY record-somefield.&lt;BR /&gt;       … record-somefield ...&lt;BR /&gt;ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 31 Jan 2023 22:55:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-group-by-external-loop-variable-field-symbol/m-p/12679910#M2016886</guid>
      <dc:creator>nomssi</dc:creator>
      <dc:date>2023-01-31T22:55:55Z</dc:date>
    </item>
    <item>
      <title>Re: LOOP AT GROUP BY external loop variable/field symbol</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-group-by-external-loop-variable-field-symbol/m-p/12679911#M2016887</link>
      <description>&lt;P&gt;easier and &lt;STRONG&gt;more legible&lt;/STRONG&gt; maybe, because I personally don't see a better alternative.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 07:03:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-group-by-external-loop-variable-field-symbol/m-p/12679911#M2016887</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2023-02-01T07:03:44Z</dc:date>
    </item>
    <item>
      <title>Re: LOOP AT GROUP BY external loop variable/field symbol</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-group-by-external-loop-variable-field-symbol/m-p/12679912#M2016888</link>
      <description>&lt;P&gt;The declaration is used for grouping. In GROUP BY, the line to be examined should be usable in expressions of any complexity, e.g. method call.&lt;/P&gt;&lt;P&gt;This is not possible without binding to a symbol.&lt;/P&gt;&lt;P&gt;If a group symbol is defined, the variable is meaningless after grouping and becomes unbound.&lt;/P&gt;&lt;P&gt;If no group symbol is defined, it takes a representative of the group in each iteration.&lt;/P&gt;&lt;P&gt;Documented in the ABAP Keyword Documentation &lt;A href="https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abaploop_at_itab_group_by.htm"&gt;here&lt;/A&gt;.  &lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 11:03:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-group-by-external-loop-variable-field-symbol/m-p/12679912#M2016888</guid>
      <dc:creator>AndreaUS</dc:creator>
      <dc:date>2023-02-01T11:03:21Z</dc:date>
    </item>
    <item>
      <title>Re: LOOP AT GROUP BY external loop variable/field symbol</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-group-by-external-loop-variable-field-symbol/m-p/12679913#M2016889</link>
      <description>&lt;P&gt;Maybe I "overengineered" your question &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;&lt;P&gt;even SAP people don't explain how the syntax was designed (for now)&lt;/P&gt;&lt;P&gt;(if the question was only about the reason why it's initial, Andrea answered)&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 11:47:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-group-by-external-loop-variable-field-symbol/m-p/12679913#M2016889</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2023-02-01T11:47:51Z</dc:date>
    </item>
    <item>
      <title>Re: LOOP AT GROUP BY external loop variable/field symbol</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-group-by-external-loop-variable-field-symbol/m-p/12679914#M2016890</link>
      <description>&lt;P&gt;Thank you so much Andrea for taking time to answer and for the excellent answer, which made me understand. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Here is a little code I tried to test what I understood from you:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;REPORT test.
CLASS lcl_report DEFINITION.
  PUBLIC SECTION.
    TYPES BEGIN OF idx_val.
    TYPES idx TYPE i.
    TYPES val TYPE string.
    TYPES END OF idx_val.
    TYPES idx_val_tab TYPE STANDARD TABLE OF idx_val WITH DEFAULT KEY.

    METHODS main.
    METHODS even_odd IMPORTING idx           TYPE i
                     RETURNING VALUE(result) TYPE string.

ENDCLASS.

CLASS lcl_report IMPLEMENTATION.
  METHOD main.
    DATA(table) = VALUE idx_val_tab( ( idx = 1 val = 'one' )
                                     ( idx = 2 val =  'two' )
                                     ( idx = 3 val =  'three' )
                                     ( idx = 4 val =  'four' )
                                     ( idx = 5 val =  'five' )
                                     ( idx = 6 val =  'six' ) ).
    LOOP AT table INTO DATA(record)
      GROUP BY ( index_key = even_odd( idx = record-idx  ) )
      ASSIGNING FIELD-SYMBOL(&amp;lt;group&amp;gt;).
      WRITE: / '&amp;lt;group&amp;gt;-index_key:', &amp;lt;group&amp;gt;-index_key.
      LOOP AT GROUP &amp;lt;group&amp;gt; ASSIGNING FIELD-SYMBOL(&amp;lt;group_member&amp;gt;).
        WRITE: / '&amp;lt;group_member&amp;gt;', &amp;lt;group_member&amp;gt;-idx.
      ENDLOOP.
    ENDLOOP.
  ENDMETHOD.
  METHOD even_odd.
    WRITE: / 'METHOD even_or_zero'.
    WRITE: 'idx: ', idx.
    IF idx MOD 2 EQ 0.
      result = 'even'.
    ELSE.
      result = 'odd'.
    ENDIF.
    WRITE: 'result: ', result.
  ENDMETHOD.
ENDCLASS.

START-OF-SELECTION.
  DATA(report) = NEW lcl_report( ).
  report-&amp;gt;main( ).&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 01 Feb 2023 12:44:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-group-by-external-loop-variable-field-symbol/m-p/12679914#M2016890</guid>
      <dc:creator>AlbertoR</dc:creator>
      <dc:date>2023-02-01T12:44:48Z</dc:date>
    </item>
    <item>
      <title>Re: LOOP AT GROUP BY external loop variable/field symbol</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-group-by-external-loop-variable-field-symbol/m-p/12679915#M2016891</link>
      <description>&lt;P&gt;This might be worth to look at:too:&lt;/P&gt;&lt;P&gt;&lt;A href="https://blogs.sap.com/2016/06/23/group-by-for-internal-tables-step-by-stepc/"&gt;GROUP BY for Internal Tables – Step by Step | SAP Blogs&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 13:26:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-group-by-external-loop-variable-field-symbol/m-p/12679915#M2016891</guid>
      <dc:creator>retired_member</dc:creator>
      <dc:date>2023-02-01T13:26:20Z</dc:date>
    </item>
  </channel>
</rss>

