on 03-01-2019 2:03 PM
Hi,
I don't know how the MDK handles OData associations and navigation and I couldn't find anything useful in the documentation or the different blogs.
I have the following data model:
entity Reports {
key ID: UUID;
expenses: Composition of many Expenses on expenses.report = $self;
}
entity Expenses {
key ID: UUID;
report: Association to Reports;
}
I'd like to display the expenses associated to a report on a detail page. However I don't know how to achieve this. Maybe using the ReadLink property?
Here's how I can get the expenses for a given report using my OData service:
https://hostname:443/odata/v2/ExpensesService/Reports(guid'039f38bd-bd83-49b2-b3b8-793a012478bb')/expenses
Note: the generated list/detail application gives me an error and the expenses are not displayed (see https://answers.sap.com/questions/766202/mdk-read-entityset-failed-error-missing-property.html)
Cheers,
Pierre
Hello,
I also face a similar issue. I need to populate ShipTo list picker in my form, based on value selected for Customer list picker. Attaching metadata metadata.txt of my service. the solution provided by Michael above does not work for me!
Please help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Aanchal,
I see you have also posted a new question for this issue as well. That is the preferred path as it will get the most visibility. Unless someone is directly following this question they may not see your post (I didn't).
--Bill
Hi Pierre,
did you tried the following target definition for your table in detailscreen:
"Target": {
"EntitySet": "{{#Property:@odata.readLink}}/expenses",
"Service": "<yourMdkService>.service"
},
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Pierre,
Can you attach the $metadata for your service? It would be helpful to see how this is being represented in your application. Also are you trying to consume the service as online or offline?
--Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi bill.froelich,
This is a simple online app. Here's the metadata:
<?xml version='1.0' encoding='UTF-8'?>
<edmx:Edmx
xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx" Version="1.0"
xmlns:sap="http://www.sap.com/Protocols/SAPData"
xmlns:ux="http://www.sap.com/Protocols/OData4SAP/UX"
xmlns:gp="http://www.sap.com/Protocols/SAPData/GenericPlayer">
<edmx:DataServices m:DataServiceVersion="2.0"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<Schema Namespace="ExpensesService"
xmlns="http://schemas.microsoft.com/ado/2008/09/edm">
<EntityType Name="Categories">
<Key>
<PropertyRef Name="ID"/>
</Key>
<Property Name="ID" Type="Edm.Int32" Nullable="false"/>
<Property Name="name" Type="Edm.String"/>
</EntityType>
<EntityType Name="Countries">
<Key>
<PropertyRef Name="code"/>
</Key>
<Property Name="code" Type="Edm.String" Nullable="false" MaxLength="3"/>
<Property Name="name" Type="Edm.String"/>
<Property Name="descr" Type="Edm.String"/>
</EntityType>
<EntityType Name="Currencies">
<Key>
<PropertyRef Name="code"/>
</Key>
<Property Name="code" Type="Edm.String" Nullable="false" MaxLength="3"/>
<Property Name="name" Type="Edm.String"/>
</EntityType>
<EntityType Name="Expenses">
<Key>
<PropertyRef Name="ID"/>
</Key>
<Property Name="ID" Type="Edm.Guid" Nullable="false"/>
<Property Name="price" Type="Edm.Decimal" Precision="8" Scale="2"/>
<Property Name="date" Type="Edm.DateTime" sap:display-format="Date"/>
<Property Name="reason" Type="Edm.String"/>
<Property Name="category_ID" Type="Edm.Int32"/>
<Property Name="currency_code" Type="Edm.String" MaxLength="3"/>
<Property Name="report_ID" Type="Edm.Guid"/>
<NavigationProperty Name="category" Relationship="ExpensesService.Expenses_category" FromRole="Expenses" ToRole="Categories"/>
<NavigationProperty Name="currency" Relationship="ExpensesService.Expenses_currency" FromRole="Expenses" ToRole="Currencies"/>
<NavigationProperty Name="report" Relationship="ExpensesService.Expenses_report" FromRole="Expenses" ToRole="Reports"/>
</EntityType>
<EntityType Name="Reports">
<Key>
<PropertyRef Name="ID"/>
</Key>
<Property Name="ID" Type="Edm.Guid" Nullable="false"/>
<Property Name="startDate" Type="Edm.DateTime" sap:display-format="Date"/>
<Property Name="endDate" Type="Edm.DateTime" sap:display-format="Date"/>
<Property Name="reason" Type="Edm.String"/>
<Property Name="status" Type="Edm.Int32"/>
<Property Name="country_code" Type="Edm.String" MaxLength="3"/>
<NavigationProperty Name="country" Relationship="ExpensesService.Reports_country" FromRole="Reports" ToRole="Countries"/>
<NavigationProperty Name="expenses" Relationship="ExpensesService.Expenses_report" FromRole="Reports" ToRole="Expenses"/>
</EntityType>
<Association Name="Expenses_category">
<End Type="ExpensesService.Expenses" Multiplicity="*" Role="Expenses"/>
<End Type="ExpensesService.Categories" Multiplicity="0..1" Role="Categories"/>
<ReferentialConstraint>
<Principal Role="Categories">
<PropertyRef Name="ID"/>
</Principal>
<Dependent Role="Expenses">
<PropertyRef Name="category_ID"/>
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="Expenses_currency">
<End Type="ExpensesService.Expenses" Multiplicity="*" Role="Expenses"/>
<End Type="ExpensesService.Currencies" Multiplicity="0..1" Role="Currencies"/>
<ReferentialConstraint>
<Principal Role="Currencies">
<PropertyRef Name="code"/>
</Principal>
<Dependent Role="Expenses">
<PropertyRef Name="currency_code"/>
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="Expenses_report">
<End Type="ExpensesService.Expenses" Multiplicity="*" Role="Expenses"/>
<End Type="ExpensesService.Reports" Multiplicity="0..1" Role="Reports"/>
<ReferentialConstraint>
<Principal Role="Reports">
<PropertyRef Name="ID"/>
</Principal>
<Dependent Role="Expenses">
<PropertyRef Name="report_ID"/>
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="Reports_country">
<End Type="ExpensesService.Reports" Multiplicity="*" Role="Reports"/>
<End Type="ExpensesService.Countries" Multiplicity="0..1" Role="Countries"/>
<ReferentialConstraint>
<Principal Role="Countries">
<PropertyRef Name="code"/>
</Principal>
<Dependent Role="Reports">
<PropertyRef Name="country_code"/>
</Dependent>
</ReferentialConstraint>
</Association>
<EntityContainer Name="EntityContainer" m:IsDefaultEntityContainer="true">
<EntitySet Name="Categories" EntityType="ExpensesService.Categories"/>
<EntitySet Name="Countries" EntityType="ExpensesService.Countries"/>
<EntitySet Name="Currencies" EntityType="ExpensesService.Currencies"/>
<EntitySet Name="Expenses" EntityType="ExpensesService.Expenses"/>
<EntitySet Name="Reports" EntityType="ExpensesService.Reports"/>
<AssociationSet Name="Expenses_category" Association="ExpensesService.Expenses_category">
<End EntitySet="Expenses" Role="Expenses"/>
<End EntitySet="Categories" Role="Categories"/>
</AssociationSet>
<AssociationSet Name="Expenses_currency" Association="ExpensesService.Expenses_currency">
<End EntitySet="Expenses" Role="Expenses"/>
<End EntitySet="Currencies" Role="Currencies"/>
</AssociationSet>
<AssociationSet Name="Expenses_report" Association="ExpensesService.Expenses_report">
<End EntitySet="Expenses" Role="Expenses"/>
<End EntitySet="Reports" Role="Reports"/>
</AssociationSet>
<AssociationSet Name="Reports_country" Association="ExpensesService.Reports_country">
<End EntitySet="Reports" Role="Reports"/>
<End EntitySet="Countries" Role="Countries"/>
</AssociationSet>
</EntityContainer>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
Cheers,
Pierre
User | Count |
---|---|
84 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.