I have seen many tutorials for SAP RAP CDS annotations for Fiori Elements.. I already managed to show the relation "composition" [1-1] to a sub-entity (e.g from Users to TodoItems), but only with the relation "composition of...":

I just could not manage to show the list items in a table for associations...

EDIT: apparently you can model parent-child relations only with compositions, associations are only for importing fields to other entities...

define root view entity Z_USERS_CDS as select from z_fs_users as Users

composition [0..*] of Z_TODOS_CDS as _Todos
association [0..1] to Z_COMPANIES_CDS as _Companies on $projection.Companyid = _Companies.Id
association [0..*] to Z_RELPRODUSERS_CDS as _ToProducts on $projection.Id = _ToProducts.Userid
{
    key Users.id as Id,
    Users.uuid as Uuid,
...
}

and on Todos entity:

define view entity Z_TODOS_CDS as select from z_fs_todos as Todos
association to parent Z_USERS_CDS as _User on $projection.Userid = _User.Id...

now in the projection view for the users, I have to redirect Todos to composition child in order to make the association work and display Todos in object page as "Line items" (table items):

define root view entity Z_ZC_USERS_CDS
as projection on Z_USERS_CDS
{
  key Id,
  Uuid,
  Firstname,
  _Todos: redirected to composition child Z_ZC_TODOS_CDS,
  ...
}

which then looks like this: enter image description here

The problem that I have is, that I can't display associations [0..1] or [0..*] to other tables (with their primary key etc.) in the Fiori Elements "object sub-page" (from list report page). The line items from table "Company" or UsersTOProducts relationship (m:n) do not show up in fiori elements no matter what annotations I'm trying out... Has anybody an idea how to do it? Or is it not possible with annotation, only with compositions?

0

There are 0 answers