cancel
Showing results for 
Search instead for 
Did you mean: 

On-Premise: CDS Hierarchy for OData V2

andre_katz_88
Explorer
0 Kudos
466

Hello Gurus,

I have a RAP based Fiori App (OData V2).
On the app's List Report page there is a list of all my Products and some Products have Sub-Products (Parent-Child Relationship). Currently the Products are displayed in a Responsive Table as a flat structure, but I want to display them in a Tree Table.

I researched this question and found that I need to create a hierarchy using CDS views and only then make some additional changes on the frontend side.
I followed the guide to create a hierarchy and expose it (code below), but to no avail.

Would be grateful for any help (hint, links, articles) from your side.

Regards,
Andre

  1. Basic View

 

 

 

define view entity Z_I_ProductItem
  as select from zt_product_i
  association [0..1] to Z_I_ProductItem as _ParentProductItem on $projection.ParentGUID = _ParentProductItem.ProductGUID
{
  key product_guid as ProductGUID,
      product_name as ProductName,
      parent_guid  as ParentGUID,
      _ParentProductItem
}​

 

 

 

  • Hierarchy View

 

 

 

define hierarchy Z_I_ProductItemHier
  as parent child hierarchy(
    source Z_I_ProductItem
    child to parent association _ParentProductItem
    start where
      ParentGUID is initial
    siblings order by
      ProductName ascending
  )
{
  key ProductGUID,
      ParentGUID
}​

 

 

 

  • Transaction Processing View

 

 

 

define view entity Z_I_ProductItemTP
  as select from Z_I_ProductItem as _ProductItem
{
  key _ProductItem.ProductGUID,
  // Some fields
  ParentGUID,
  _ParentProductItem
}​

 

 

 

  • Consumption View

 

 

 

@OData.hierarchy.recursiveHierarchy:[{ entity.name: 'Z_I_ProdItemHier' }]​
define view entity Z_C_ProductItemListRepPage
  as projection on Z_I_ProductItemTP as _ProductItemTP
{
  key ProductGUID,
      ProductName,
      ParentGUID,
      _ParentProductItem
}

 

 

 

Accepted Solutions (0)

Answers (0)