Skip to Content
1
Jan 31, 2023 at 03:54 PM

LOOP AT GROUP BY external loop variable/field symbol

406 Views Last edit Feb 01, 2023 at 12:34 PM 4 rev

Dear all,

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.

I have the following code:

      LOOP AT internal_table INTO DATA(record)
        GROUP BY ( criteria = record-somefield )
        ASSIGNING FIELD-SYMBOL(<group>).
            "some code here
        LOOP AT GROUP <group> ASSIGNING FIELD-SYMBOL(<group_member>).
           "other code: here we can modify the group member using <group_member>
        ENDLOOP.
      ENDLOOP.

I cannot understand the reason to declare the variable "record", in the external part of the loop: it stays initial for the whole time.

I checked several blogs and documentation, so I ask in case somebody knows.

Thanks a lot in advance for your precious help!