I want to aggregate some specific data in a RFC module. The module takes several parameters like timestamps but also dimensions that specify the kind of aggregation.
For example I want to aggregate all contracts in a specific timerange for the several sales orgs in my system.
For this I use the GROUP BY functionality for internal tables like here:
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.
The group-field may change for different cases also it should be possible to use two group-fields in order to e.g. aggregate all sales-orgs and the material they sold.
My question know is, how could I do the GROUP-BY dynamically without the need to programm every combination of group-fields manually?
Thank you very much in advance