Skip to Content
-1
Aug 08, 2023 at 03:59 PM

complex challenged Loop on internal table with

254 Views Last edit Aug 09, 2023 at 08:27 AM 3 rev

Hi Expert, ich have a Database which contain Parent and Child Groups..

Some Groups has Child but others not ?

It can be more than 6 Groups linked together with this Child relation, other groups can has on Child group..

How can I replace the following Loop with another one which can be more dynamically ?

SELECT * FROM zgroups INTO TABLE @DATA(lt_groups).
LOOP AT lt_groups ASSIGNING FIELD-SYMBOL(<ls_groups>).
  SELECT * FROM zgroups INTO TABLE @DATA(lt_groups_kind) WHERE group_parent = @<ls_groups>-group_id.
  LOOP AT lt_groups_kind ASSIGNING FIELD-SYMBOL(<ls_groups_kind>) .
    SELECT * FROM zgroups INTO TABLE @DATA(lt_groups_kind_sub) WHERE group_parent = @<ls_groups_kind>-group_id.
    LOOP AT lt_groups_kind_sub ASSIGNING FIELD-SYMBOL(<ls_groups_kind_sub>) .
      SELECT * FROM zgroups INTO TABLE @DATA(lt_groups_kind_sub_sub) WHERE group_parent = @<ls_groups_kind_sub>-group_id.
* ETC+++++++  loop again             
    ENDLOOP.
  ENDLOOP.
ENDLOOP.

Please, any Idea will be appreciated.

Regards,