Skip to Content
0
Jun 06, 2018 at 10:04 AM

How to create hierarchy CDS view?

1767 Views

Hi experts,

I'm trying to create A very simple hierarchy without hierarchy directory

My source code is as follows. I try to activate these source at the same time, but these got errors.

Do you have any idea for these errors?

Error:

Basis object ZGL_HIER does not exist or is not active

SAP object VIEW GLHIERV cannot be assigned to package XXXX

@AbapCatalog.sqlViewName: 'GLHIERV'
@AbapCatalog.compiler.compareFilter: true
@EndUserText.label: 'ZGL_HIER'
@ObjectModel:{dataCategory: #HIERARCHY}
@Hierarchy.parentChild.name: 'HIER1'
@Hierarchy.parentChild.label: 'GL HIER1'
@Hierarchy.parentChild: 
{ recurse: {parent: 'ParentNode', child: 'ChildNode'},
siblingsOrder: { by:'ParentNode', direction: #DESC},
orphanedNode.handling: #ROOT_NODES
}
@AccessControl.authorizationCheck: #NOT_REQUIRED
define view ZGL_HIER as select from zzglhier1
association[0..*] to ZGL_COUNTRY as _ZGL_COUNTRY on $projection.ChildNode=_ZGL_COUNTRY.country
{
    key zparentnode as ParentNode,
    @ObjectModel.foreignKey.association: '_ZGL_COUNTRY'
    key zchildnode as ChildNode,
    _ZGL_COUNTRY
}

@AbapCatalog.sqlViewName: 'ZGL_COUNTRYV'
@AbapCatalog.compiler.compareFilter: true
@EndUserText.label: 'ZGL_COUNTRY'
@Analytics.dataCategory: #DIMENSION
@ObjectModel.representativeKey: 'Country'
@AccessControl.authorizationCheck: #NOT_REQUIRED
define view ZGL_COUNTRY as select from zzglcountry
association[0..*] to ZGL_HIER as _GLCOUNTRY_Hier1 on $projection.countory = _GLCOUNTRY_Hier1.ChildNode
{
    @ObjectModel.Hierarchy.association: '_GLCOUNTRY_Hier1'
    @EndUserText.label: 'Country'
    key zzglcountry.zglcountry as country,
    _GLCOUNTRY_Hier1
}

Regards,

Arisa

Attachments

table1.png (16.8 kB)
table2.png (13.9 kB)