Hi all
I have created a CDS view as follows:
define view YGAC_I_SINGLE_COMPOSITE_ROLE
with parameters
pm_role2 : grac_roleid
as select from YGAC_I_ROLE_RS
association [1..1] to YGAC_I_ROLE_CONNECTION as _Connection on _Connection.RefRoleId = $projection.RoleId2
association [1..1] to YGAC_I_ROLE as _Role on _Role.RoleId = $projection.RoleId2
{
key RoleId2,
RelationType,
_Connection[inner].Connector,
_Role[inner].RoleName,
_Role[inner].RoleId,
_Connection,
_Role
} where YGAC_I_ROLE_RS.RoleId2 = $parameters.pm_role2
The compiler shows warnings:
Cardinality 1 of Association _CONNECTION does not match to the ON-condition ygac_i_single_composite_role.asddls /DA4_010_i0000168_en/.adt/ddic/ddlsources/ygac_i_single_composite_role/ygac_i_single_composite_role.asddls line 10 ABAP Syntax Check Problem Key Definitions of YGAC_I_SINGLE_COMPOSITE_ROLE and YGAC_I_ROLE_RS are different, ROLEID1 is missing in key of YGAC_I_SINGLE_COMPOSITE_ROLE ygac_i_single_composite_role.asddls /DA4_010_i0000168_en/.adt/ddic/ddlsources/ygac_i_single_composite_role/ygac_i_single_composite_role.asddls line 6 ABAP Syntax Check Problem
When I start the Data Preview editor, it shows:

As you can see, I have got key duplication on the column RoleId2 although the column RoleId2 is defined as thee primary key.
So maybe the view YGAC_I_ROLE_CONNECTION is responsible for the problem, because the association
association [1..1] to YGAC_I_ROLE_CONNECTION as _Connection on _Connection.RefRoleId = $projection.RoleId2
is not related to the primary key on YGAC_I_ROLE_CONNECTION:
define view YGAC_I_ROLE_CONNECTION
as select from gracrlconn
{
key role_id as RoleId,
connector as Connector,
role_name as RoleName,
ac_ref_role_id as RefRoleId,
updated_on as UpdatedOn,
excluded as Excluded
}
How to force the column RoleId2 to be unique?
Thanks