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