cancel
Showing results for 
Search instead for 
Did you mean: 

Issue building Custom Hierarchy in ABAP CDS views

elgoher
Explorer
0 Kudos

Hi Abapers,

I'm new building Custom Hierarchy in ABAP CDS views, and I follow this tutorial but the results that shows this tutorial are not the same that mine, so What I trying to do is to get the Hierarchy of Commitment items master data like when I use t-code FM3G.

but when I build my custom CDS there's not Hierarchy

so these are the cds I build

this is the Hierarchy cds

@VDM.viewType: #BASIC
@ObjectModel: { dataCategory: #HIERARCHY }
@AbapCatalog.sqlViewName: 'ZVIFMCIH'
@Hierarchy.parentChild.name: 'FIPEX_01'
@Hierarchy.parentChild.label: 'Posición presupuestaria 01'
@Hierarchy.parentChild:
{ recurse:          {   parent: 'ParentNode',   child:  'HierarchyNode'   },
  siblingsOrder:    {   by: 'HierarchyNode',    direction: 'ASC'   },
  orphanedNode.handling: #ROOT_NODES
// rootNode.visibility: #DO_NOT_ADD_ROOT_NODE
  }
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Posiciones presupuestarias datos maestros'


/*+[hideWarning] { "IDS" : [ "KEY_CHECK" ]  } */
define view ZI_FMCI_H_01
  as select from fmci as object
    inner join   fmci as relation on  relation.fipex = object.fipex
                                  and relation.kateg = '2'
  association [0..*] to ZI_FMCI_DIM_ as _ZI_FMCI_DIM_01 on $projection.PosPre = _ZI_FMCI_DIM_01.PosPre
{
  key      object.fipex                as HierarchyNode,
           relation.fipup              as ParentNode,
           @ObjectModel.foreignKey.association: '_ZI_FMCI_DIM_01'
           relation.fipex              as PosPre,
           @ObjectModel.foreignKey.association: '_ZI_FMCI_DIM_01'
           relation.fipup              as PosPreM,


           _ZI_FMCI_DIM_01
} 
 

and this is the dimension cds

@AbapCatalog.sqlViewName: 'ZVI_FMCIDIM'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'test analytics'
@VDM.viewType: #BASIC
@Analytics: { dataCategory: #DIMENSION, dataExtraction.enabled: true }
@ObjectModel.representativeKey: 'PosPre'
/*+[hideWarning] { "IDS" : [ "CARDINALITY_CHECK", "KEY_CHECK" ]  } */
define view ZI_FMCI_DIM_
  as select from fmci
  association [0..*] to ZI_FMCI_H_01 as _Fmci_Hier on  $projection.PosPre = _Fmci_Hier.PosPre
  association [1..1] to fmcit        as pospret    on  $projection.PosPre = pospret.fipex
                                                   and pospret.fikrs      = 'UEAN'
                                                   and pospret.spras      = $session.system_language
{
              @ObjectModel.Hierarchy.association: '_Fmci_Hier'
              @ObjectModel.text.element:  [ 'Name' ]
              @EndUserText.label: 'PosPre'
  key         fmci.fipex    as PosPre, //  PosPre
              fmci.fikrs,
              fmci.gjahr,
              fmci.fipup,
              fmci.fipex,
              /*Assosiations*/
              _Fmci_Hier,
              /*Text*/
              @Semantics.text: true
              pospret.mctxt as PosPreName
} 

so I don't know what else I can do to make it work, any suggestion are accepted

regards

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member249109
Active Participant

Maybe the hierarchy annotation is not correctly set up? According to the documentation, the Hierarchy.parentChild is an array. So try to enclose this annotation in brackets

elgoher
Explorer
0 Kudos

Hi Marco,

thanks for the help, I did as you said and it works, but how can I show the text of each row in Hierarchy, both parent and childs

thanks in advance