Skip to Content

ABAP CDS Recursive Hierarchy

Dear Members,

I'm trying to create a recursive CDS view hierarchy with annotations, and expose it as OData service. Here is what I'm doing to prototype in eclipse connected to an ABAP backend:

@AbapCatalog.sqlViewName: 'zv_hier_demo' @AbapCatalog.compiler.compareFilter: true @AccessControl.authorizationCheck: #NOT_REQUIRED @EndUserText.label: 'Hierarchy Demo' @Analytics : { dataCategory : #DIMENSION } @Hierarchy.parentChild : [ { 
name : 'Cateories', 
recurseBy : '_ParentCategory', 
multipleParents : false } ] 
@OData.publish: true 
define view Zdemo_I_Hierarchy as select from zdemo_hierarchy 
association [0..*] to zdemo_i_hierarchy as _ParentCategory 
on $projection.ParentId = _ParentCategory.Id 
{ 
key zdemo_hierarchy.id as Id, 
zdemo_hierarchy.short_text as ShortText, 
zdemo_hierarchy.parent_id as ParentId, 
cast( zdemo_hierarchy.active as Boolean ) as Active, _
ParentCategory 
} 

The DB table behind has the below fields:

CLIENT MANDT

ID INT4

PARENT_ID INT4

ACTIVE BOOLE_D

SHORT_TEXT CHAR40

After activating the View I'm trying to import annotations in WebIDE, but nothing found. Should I have something available or not at all ? Maybe I need to manually define the tree the parent-child relationshio fields in my UI5 View?
Thank you Attila

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Oct 20, 2017 at 03:52 PM

    HI , I am kind of facing the same problem. My CDS view returns only the immediate parent. Did you get a solution for this ?

    Thanks and Regards,

    Vasu

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Vasu,

      I stopped spending more time on this. It was not well documented, and the probablity for success fumbling in the darkness was very low. Since it was required for a prototype, and we faced problems at the very beginning, I made the hierarchy without CDS manually coding in the GW DPC and MPC classes.

      Attila