‎2020 Jun 17 6:49 PM
Hello. I hope you can help me.
I used the BAPI_COSTELEMENTGRP_GETDETAIL function in order to get the cost elements, but i need also the hierarchy that is given in the returning table of the function and for example it is shown:

This table using and algorithm can give me the follow hierarchy:

I would like that the algorithm give me a table with for example:
MOD
Personal Expenses / Remunerations / Salaries
Personal Expenses / Remunerations / Commissions,
etc.
I tried the following:
But is not working. I hope you can help me.
Greetings
‎2020 Jun 17 7:04 PM
Hello hvillanueva
Try this (might contain some typos).
DATA:
lv_description TYPE string,
lt_descriptions TYPE TABLE OF string.
lwa_desc-sign = 'I'.
lwa_desc-option = 'EQ'.
LOOP AT lt_hierarchynodes REFERENCE INTO DATA(ld_node).
DATA(lv_hierarchy_level_index) = ld_node->hierlevel + 1.
DELETE lt_descriptions FROM lv_hierarchy_level_index.
lv_description = ld_node->descript.
APPEND lv_description TO lt_descriptions.
IF ld_node->valcount > 0.
CLEAR lwa_desc-low.
LOOP AT lt_descriptions INTO lv_description.
CONCATENATE lwa_desc-low lv_description INTO lwa_desc-low SEPARATED BY space.
ENDLOOP.
CONDENSE lwa_desc-low.
APPEND lwa_desc TO lr_desc.
ENDIF.
ENDLOOP.Kind regards,‎2020 Jun 17 6:51 PM
I tried the following but is not working:
LOOP AT lt_hierarchynodes ASSIGNING FIELD-SYMBOL(<fs_nodevalues>).
CLEAR lwa_desc.
AT NEW hierlevel.
ENDAT.
lwa_desc-sign = 'I'.
lwa_desc-option = 'EQ'.
CONCATENATE l_desc space <fs_nodevalues>-descript INTO l_desc.
lwa_desc-low = l_desc.
IF <fs_nodevalues>-valcount = 1.
APPEND lwa_desc TO lr_desc.
CLEAR l_desc.
ENDIF.
ENDLOOP.
‎2020 Jun 17 7:04 PM
Hello hvillanueva
Try this (might contain some typos).
DATA:
lv_description TYPE string,
lt_descriptions TYPE TABLE OF string.
lwa_desc-sign = 'I'.
lwa_desc-option = 'EQ'.
LOOP AT lt_hierarchynodes REFERENCE INTO DATA(ld_node).
DATA(lv_hierarchy_level_index) = ld_node->hierlevel + 1.
DELETE lt_descriptions FROM lv_hierarchy_level_index.
lv_description = ld_node->descript.
APPEND lv_description TO lt_descriptions.
IF ld_node->valcount > 0.
CLEAR lwa_desc-low.
LOOP AT lt_descriptions INTO lv_description.
CONCATENATE lwa_desc-low lv_description INTO lwa_desc-low SEPARATED BY space.
ENDLOOP.
CONDENSE lwa_desc-low.
APPEND lwa_desc TO lr_desc.
ENDIF.
ENDLOOP.Kind regards,‎2020 Jun 18 3:45 PM
‎2020 Jun 18 3:45 PM
‎2020 Jun 18 3:55 PM