cancel
Showing results for 
Search instead for 
Did you mean: 

Navigation Property is not created in Service Binding using association

0 Kudos
421

Hello 🙂

I created a CDS view using view entity. The view selects from a database table and associates with another CDS view, that selects from another database table.

The database tables are connected using foreign keys. 

After exposing the CDS view in the service definition I would expect the service binding to show up the navigation property. But this does not appear.

CDS view with association

@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Terminvarianten für Plabo'
define root view entity ZI_PLABO_DATVAR
  as select from zplabo_datvar
  association [0..1] to ZC_PLABO_Variant     as _variant     on  _variant.Variant = zplabo_datvar.variant
  association [0..*] to ZI_PLABO_DATVARSTP   as _datVarStep  on  $projection.variant = _datVarStep.plabo_variant
  association [1..1] to ZI_PLABO_DEFAULTICON as _defaultIcon on  $projection.variant     = _defaultIcon.variant
                                                             and $projection.date_variant = _defaultIcon.date_variant
                                                             and $projection.is_default     = _defaultIcon.is_default
{
  key variant,
  key date_variant,
      name,
      is_default,
      created_by,
      _variant,
      _datVarStep,
      _defaultIcon
}

CDS projection view

@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Terminvarianten für Plabo'
define root view entity ZC_PLABO_DATVAR
  provider contract transactional_query
  as projection on ZI_PLABO_DATVAR

{
      @ObjectModel.text.element: [ 'PlaboVariantName' ]
  key variant                    as PlaboVariantId,
      @ObjectModel.text.element: [ 'TerminVariantName' ]
  key date_variant               as TerminVariantId,
      name                       as TerminVariantName,
      is_default                 as IsDefault,
      created_by                 as CreatedBy,
      _variant.VariantName       as PlaboVariantName,
      _datVarStep,
      _defaultIcon.IsDefaultIcon as DefaultIcon
}

 Service definition:

@EndUserText.label: 'Service Definition für Termin-Varianten'
define service ZPLABO_DATVARS {
  expose ZC_PLABO_DATVAR as PlaboTerminVariante;
  expose ZC_PLABO_DATVARSTP as PlaboTerminVarianteStep;
}

Service binding:

simonblaser_haufe_0-1711540749551.png

 

There should be a navigation property from PlaboTerminVariante to PlaboTerminVarianteStep, propably called to_PlaboTerminVarianteStep. 


What am I missing?

 

Thank you already in advance.

Kind regards, 
Simon

 

 

Accepted Solutions (0)

Answers (1)

Answers (1)

shankha_saha
Explorer
0 Kudos

Hi Simon,

You might have found the solution, if not, then please check the below

https://community.sap.com/t5/technology-q-a/abap-in-scp-cds-views-generate-navigation-property-assoc...

You need to write redirection from parent to child and child to parent in your CDS.

at Parent CDS
/* Associations */
_<toChildEntity>: redirected to composition child <Child_Entity_CDS>
at Child CDS
/* Associations */
_<toParentEntity>: redirected to parent <Parent_Entity_CDS>

 

I hope this helps 🙂

Thanks

Shankha