on 2016 Jun 02 11:25 PM
Hi All,
I need to write an XS OData service which will be consumed by a smart table in UI5. The UI5 smart controls require special annotations to be provided in the metadata. Can I please know how these annotations can be generated as part of the xs odata $metadata? If xsodata cannot provide this, how can we generate this metadata file? We are currently running on Hana XS Advanced (SP12).
I have already tried including the following code after the odata service definition, but this did not produce the required annotations:
annotations {
enable OData4SAP;
}
Any help is greatly appreciated.
Thanks,
Isuru
PS - Here is a sample metadata file required by Smart Tables. Annotations are from line 28 to 45:
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:sap="http://www.sap.com/Protocols/SAPData">
<edmx:Reference
xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx">
<edmx:Include Namespace="com.sap.vocabularies.UI.v1" Alias="UI"/>
</edmx:Reference>
<edmx:DataServices m:DataServiceVersion="2.0">
<Schema Namespace="SmartTbl" xml:lang="de" sap:schema-version="1 " xmlns="http://schemas.microsoft.com/ado/2008/09/edm">
<EntityType Name="Person" sap:content-version="1">
<Key>
<PropertyRef Name="PersonID"/>
</Key>
<Property Name="PersonID" Type="Edm.String" Nullable="false" sap:creatable="false" sap:updatable="false" sap:sortable="false"
sap:filterable="false"/>
<Property Name="FirstName" Type="Edm.String" Nullable="false" sap:visible="true" sap:creatable="false" sap:updatable="false"
sap:sortable="false" sap:filterable="false"/>
<Property Name="LastName" Type="Edm.String" Nullable="false" sap:visible="true" sap:creatable="false" sap:updatable="false"
sap:sortable="false" sap:filterable="false"/>
<Property Name="Birthday" Type="Edm.DateTime" Nullable="false" sap:visible="true" sap:creatable="false" sap:updatable="false"
sap:sortable="false" sap:filterable="false"/>
</EntityType>
<EntityContainer Name="SmartTbl_Entities" m:IsDefaultEntityContainer="true" sap:supported-formats="atom json xlsx">
<EntitySet Name="Persons" EntityType="SmartTbl.Person" sap:creatable="false" sap:updatable="false" sap:deletable="false"
sap:pageable="false" sap:addressable="false" sap:content-version="1"/>
</EntityContainer>
<Annotations Target="SmartTbl.Person" xmlns="http://docs.oasis-open.org/odata/ns/edm">
<Annotation Term="com.sap.vocabularies.UI.v1.LineItem">
<Collection>
<Record Type="UI.DataField">
<PropertyValue Property="Value" Path="FirstName"/>
<Annotation Term="UI.Importance" EnumMember="UI.Importance/High"/>
</Record>
<Record Type="UI.DataField">
<PropertyValue Property="Value" Path="LastName"/>
<Annotation Term="UI.Importance" EnumMember="UI.Importance/High"/>
</Record>
<Record Type="UI.DataField">
<PropertyValue Property="Value" Path="Birthday"/>
<Annotation Term="UI.Importance" EnumMember="UI.Importance/High"/>
</Record>
</Collection>
</Annotation>
</Annotations>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
Hello Isuru,
as the documentation describes XS Advanced does not support OData Annotations at the moment (OData Service Definition Language Syntax (XS Advanced) - Introduction to Application Development and...).
You could use a local annotations file. Some insights are given e.g. in post . Using SAP Web IDE you have a good support to create such files using the Annotation Modeler.
Regards,
Florian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Isuru,
Were you able to consume an XSOData service by a smart table in UI5?
May you post an example here?
Cheers,
Severin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Severin,
kind of.. after intercepting the $metadata request and replacing the response with a local metadata file version that contains the V2 annotations (sap:label ..etc.) .. yes, I know its kind of a hack...
looks like the smartchart and/or smarttable need those V2 annotations and the local annotation file supports V4 annotations only.
Best
Miro
User | Count |
---|---|
70 | |
9 | |
8 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.