dynamic loop at group by
Mon May 10 2021 11:02:00 GMT+0000 (Coordinated Universal Time)
Saved by
@uxkjaer
LOOP AT <lt_values> ASSIGNING <ls_value>
GROUP BY (
level1 = get_part( i_ls_value = <ls_value> iv_level = mv_level1 )
level2 = get_part( i_ls_value = <ls_value> iv_level = mv_level2 )
level3 = get_part( i_ls_value = <ls_value> iv_level = mv_level3 )
level4 = get_part( i_ls_value = <ls_value> iv_level = mv_level4 )
level5 = get_part( i_ls_value = <ls_value> iv_level = mv_level5 )
level6 = get_part( i_ls_value = <ls_value> iv_level = mv_level6 ) )
ASCENDING
ASSIGNING FIELD-SYMBOL(<lft_value_group>).
CLEAR <lt_values_group>.
LOOP AT GROUP <lft_value_group> ASSIGNING FIELD-SYMBOL(<lfs_value_group>).
<lt_values_group> = VALUE #( BASE <lt_values_group> ( <lfs_value_group> ) ).
ENDLOOP.
*** Method definition ***
METHODS get_part
IMPORTING
i_ls_value TYPE any
iv_level TYPE string
RETURNING
VALUE(r_result) TYPE char10.
*** Method Implementation ***
METHOD get_part.
IF iv_level IS NOT INITIAL.
ASSIGN COMPONENT iv_level OF STRUCTURE i_ls_value TO FIELD-SYMBOL(<part>).
r_result = <part>.
ENDIF.
ENDMETHOD.
content_copyCOPY
Comments