Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to add "ReferentialConstraint" tags in metadata for BOPF parent node and its subnodes?

former_member367733
Participant
0 Kudos

Hello Experts,

We use CDS view and BOPF to handle the business project. And the BOPF object is created by CDS view annotation.

We met a problem that parent node cannot find its subnodes through navigation in Mock Server.

For example:

Parent node: ZALEX_C_1ST Navigation: to_2nd_object

Sub node: ZALEX_C_2ND

The generated metadata are the followings:

<EntityType Name="ZALEX_C_1STType" sap:label="C VIEW 1ST" sap:content-version="1">
<Key>
<PropertyRef Name="guid"/>
</Key>
<Property Name="guid" Type="Edm.Guid" Nullable="false" sap:label="UUID" sap:quickinfo="Alex test bopf"/>
<Property Name="name" Type="Edm.String" MaxLength="32" sap:display-format="UpperCase" sap:label="Description" sap:quickinfo="alex test"/>
<Property Name="status" Type="Edm.String" MaxLength="3" sap:display-format="UpperCase" sap:label="Status ID" sap:quickinfo="Alex test status"/>
<NavigationProperty Name="to_2nd_object" Relationship="ZALEX_C_1ST_CDS.assoc_1AB3351678AF3529F4D16CCCF2F09748" FromRole="FromRole_assoc_1AB3351678AF3529F4D16CCCF2F09748" ToRole="ToRole_assoc_1AB3351678AF3529F4D16CCCF2F09748"/>
</EntityType>
<EntityType Name="ZALEX_C_2NDType" sap:label="C VIEW 2ND" sap:content-version="1">
<Key>
<PropertyRef Name="guid"/>
</Key>
<Property Name="guid" Type="Edm.Guid" Nullable="false" sap:label="UUID" sap:quickinfo="Alex test bopf"/>
<Property Name="name" Type="Edm.String" MaxLength="32" sap:display-format="UpperCase" sap:label="Description" sap:quickinfo="alex test"/>
<Property Name="parent_guid" Type="Edm.Guid" sap:label="UUID" sap:quickinfo="Alex test bopf" sap:value-list="standard"/>
<NavigationProperty Name="to_1st_object" Relationship="ZALEX_C_1ST_CDS.assoc_73634C2C4DFD9BA5AF07021CD96B12E6" FromRole="FromRole_assoc_73634C2C4DFD9BA5AF07021CD96B12E6" ToRole="ToRole_assoc_73634C2C4DFD9BA5AF07021CD96B12E6"/>
</EntityType>
<Association Name="assoc_1AB3351678AF3529F4D16CCCF2F09748" sap:content-version="1">
<End Type="ZALEX_C_1ST_CDS.ZALEX_C_1STType" Multiplicity="1" Role="FromRole_assoc_1AB3351678AF3529F4D16CCCF2F09748"/>
<End Type="ZALEX_C_1ST_CDS.ZALEX_C_2NDType" Multiplicity="*" Role="ToRole_assoc_1AB3351678AF3529F4D16CCCF2F09748"/>
</Association>

If this metadata is applied in Mock Server, the parent node cannot get its subnodes through "expand" service operation.

Try to fix this problem, the metadata is modified as following:

<Association Name="assoc_1AB3351678AF3529F4D16CCCF2F09748" sap:content-version="1">
<End Type="ZALEX_C_1ST_CDS.ZALEX_C_1STType" Multiplicity="1" Role="FromRole_assoc_1AB3351678AF3529F4D16CCCF2F09748"/>
<End Type="ZALEX_C_1ST_CDS.ZALEX_C_2NDType" Multiplicity="*" Role="ToRole_assoc_1AB3351678AF3529F4D16CCCF2F09748"/>
<ReferentialConstraint>
<Principal Role="ToRole_assoc_1AB3351678AF3529F4D16CCCF2F09748">
<PropertyRef Name="parent_guid"/>
</Principal>
<Dependent Role="FromRole_assoc_1AB3351678AF3529F4D16CCCF2F09748">
<PropertyRef Name="guid"/>
</Dependent>
</ReferentialConstraint>
</Association>

Do you have suggestion to add the "ReferentialConstraint" tag in metadata for parent and child nodes?

Thank you very much for your help.

BR
Alex

0 REPLIES 0