Skip to Content
Dec 24, 2021 at 03:24 PM

Recursive Hierarchy in CAP

355 Views Last edit Dec 28, 2021 at 09:49 AM 7 rev

Hi CAP friends,

I have been struggeling with implementing a recursive hierarchy view in my CAP application.

I have a database table HierachyNode which represents an organisational hierarchy:

Customer Center 1->* Sales Organisation 1->* Country 1->* Customer.

Every node in the hierarcy can have 0...* functionalities, and when we read a node, we want to inhert all functionalities defined in the parnent nodes.

entity HierarchyNodes {<br>    key id                 : String;<br>        name               : String;<br>        parent             : Association to one HierarchyNodes;<br>        level              : Integer;<br>        lineage            : String;<br>        type               : String enum {<br>            CC;<br>            SALESORG;<br>            COUNTRY;<br>            CUSTOMER<br>        };<br>        virtual drillstate : String enum {<br>            expanded;<br>            Leaf;<br>        };<br>        functionalities    : Association to many NodeFunctionalities<br>                                 on functionalities.node = $self;<br>}<br>entity NodeFunctionalities {<br>    key node          : Association to one HierarchyNodes;<br>    key functionality :  String;<br>    key value         : String;<br>}

I found the following blog online about recursive CDS views in ABAP:

Is something similar possible in CAP? The annotations used in the blog are throwing errors. Are there examples available?

Happy holidays!