on 2024 Mar 27 12:02 PM
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:
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
Request clarification before answering.
Hi Simon,
You might have found the solution, if not, then please check the below
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
75 | |
30 | |
9 | |
8 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.