I am refering to this question: LOOP AT... GROUP BY with dynamic group key
I also want to do some dynamic GROUP-BY-Aggregations.
I want to dynamize a GROUP-BY-Statement like the following snippet:
WHEN 'vkorg'.
LOOP AT ls_output-merged_data INTO ls_tmp
GROUP BY ( sales_org = ls_tmp-sales_org
group_quantity = GROUP SIZE )
ASCENDING ASSIGNING FIELD-SYMBOL(<fs_tmp_2>).
lt_tmp_dim1 = VALUE #( BASE lt_tmp_dim1 (
sales_org = <fs_tmp_2>-sales_org
group_quantity = <fs_tmp_2>-group_quantity
) ).
ENDLOOP.
Curently I have some smiliar to this:
LOOP AT ls_output-merged_data INTO ls_tmp
GROUP BY COND #( WHEN iv_dim1 EQ 'vkorg' THEN |{ ls_tmp-sales_org }| )
ASCENDING ASSIGNING FIELD-SYMBOL(<total_group>).
LOOP AT GROUP <total_group> ASSIGNING FIELD-SYMBOL(<line_data>).
ASSIGN COMPONENT 'vkorg' OF STRUCTURE <line_data> TO FIELD-SYMBOL(<vkorg>).
EXIT.
ENDLOOP.
ENDLOOP.
The issue here is, that I also need the GROUP SIZE field. However I am not able to put it into the embedded expression like: |{ ls_tmp-sales_org GROUP SIZE }|
I tried several positions and syntax but I was not able to make it work.
Does someone did something similiar before and can help me out?