Skip to Content
0

ABAP CDS Recursive Hierarchy

Dec 29, 2016 at 07:46 PM

466

avatar image

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

avatar image
Former Member Oct 20, 2017 at 03:52 PM
0

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

Show 1 Share
10 |10000 characters needed characters left 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

0