Skip to Content

Generating annotations for SmartTable in XSOData

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
  Uri="http://server:port/sap/opu/odata/IWFND/CATALOGSERVICE;v=2/Vocabularies(TechnicalName='%2FIWBEP%2FVOC_CORE',Version='0001',SAP__Origin='')/$value"
  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>
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Jun 03, 2016 at 04:45 AM

    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 Deployment (XS Adva…).

    You could use a local annotations file. Some insights are given e.g. in post Create Smart Template Project.........SAP WEB IDE. Using SAP Web IDE you have a good support to create such files using the Annotation Modeler.

    Regards,

    Florian

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 18, 2016 at 08:32 AM

    Hi Isuru,

    Were you able to consume an XSOData service by a smart table in UI5?

    May you post an example here?

    Cheers,

    Severin

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.