Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ABAP CDS Recursive Hierarchy

Attila
Active Participant
0 Likes
4,043

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

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

2 REPLIES 2
Read only

Former Member
0 Likes
1,838

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

Read only

1,838

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