Skip to Content
0

Smart Table with Northwind odata giving error

Nov 28, 2016 at 06:28 AM

453

avatar image

Hi All,

I am developing smart table control with Northwind OData service when i run this application i am getting some error i am posting that screen shot please look on it.

And my code is :

View :

<smartTable:SmartTable id="smartTable_ResponsiveTable" smartFilterId="smartFilterBar" tableType="ResponsiveTable" editable="false" entitySet="Products" useVariantManagement="false" useTablePersonalisation="false" header="Products" showRowCount="true" useExportToExcel="false" enableAutoBinding="true"></smartTable:SmartTable>

metadata.xml

<?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" xmlns:p8="http://schemas.microsoft.com/ado/2009/02/edm/annotation"> 

<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="com.sap.wt05" sap:schema-version="1" xmlns="http://schemas.microsoft.com/ado/2008/09/edm"> 

<EntityType Name="Product"> 

<Key> <PropertyRef Name="ProductID"/> </Key>

 <Property Name="ProductID" Type="Edm.String" sap:filterable="false" sap:visible="true"/> <Property Name="ProductName" Type="Edm.String" MaxLength="30" sap:label="ProductName" sap:filterable="false" /> <Property Name="CategoryID" Type="Edm.String" sap:label="CategoryID" sap:filterable="true" /> <Property Name="UnitPrice" Type="Edm.String" MaxLength="3" sap:label="UnitPrice" sap:filterable="false" /> 

</EntityType> 

<EntityContainer m:IsDefaultEntityContainer="true" sap:supported-formats="atom json"> 

<EntitySet Name="Products" EntityType="com.sap.wt05.Product"/>

 </EntityContainer> 

<Annotations Target="com.sap.wt05.Product" xmlns="http://docs.oasis-open.org/odata/ns/edm"> <Annotation Term="com.sap.vocabularies.UI.v1.LineItem"> <Collection> <Record Type="com.sap.vocabularies.UI.v1.DataField"> <PropertyValue Property="Value" Path="ProductID"/> </Record> <Record Type="com.sap.vocabularies.UI.v1.DataField"> <PropertyValue Property="Value" Path="UnitPrice" /> </Record> <Record Type="com.sap.vocabularies.UI.v1.DataField"> <PropertyValue Property="Value" Path="ProductName" /> </Record> <Record Type="com.sap.vocabularies.UI.v1.DataField"> <PropertyValue Property="Value" Path="CategoryID" /> </Record> </Collection> </Annotation> </Annotations> <atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="self” href=”http://services.odata.org/V2/Northwind/Northwind.svc/$metadata"/> 

</Schema> 

</edmx:DataServices>

 </edmx:Edmx>

manifest.json :

"dataSources": {
			"mainService": {
				"uri": "/destinations/northwind/V2/Northwind/Northwind.svc/",
				"type": "OData",
				"settings": {
					"odataVersion": "2.0",
					"localUri": "test/metadata.xml"
				}
			}
		}

This is my code please look on it and resolve my issue.

Regards,

Sai Ram Dinesh Pallapotu

capture.png (21.2 kB)
10 |10000 characters needed characters left characters exceeded

Hi All,

Like above i'm trying to develop smart controls using JSON Model data that is instead of OData. This time without annotations and by using <itiallyVisibleFields="id,name"> i'm trying to show the data but i'm getting same error like above that is "There are no columns....."

Please say how to achieve this functionality.

Regards,
Sai Ram Dinesh Pallapotu

0
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Best Answer
Radek Chudziak Nov 28, 2016 at 02:58 PM
1

The northwind oData is not annotated. You need to annotate it in a separate annotations file e.g. annotation.xml (rather then the metadata.xml as you are doing just now) and then link it to your data source in manifest.json. If you are using WEB IDE then you can use the following: Annotation Modeller and when you create it should link it automatically. The metadata.xml file should have the annotations only if they are annotated in the backend and you have manually added it in there.

I know the documentation of Smart Table is very poor and it is hard to get your head around. The annotations are only telling which columns of the table should be initially visible. You can achieve the same by using property initiallyVisibleFields of the Smart Table

Check the following code. It should display the product name.

<sap.ui.comp.smarttable:SmartTable xmlns:sap.ui.comp.smarttable="sap.ui.comp.smarttable" 
				tableType="ResponsiveTable" header="Smart Table"
				enableAutoBinding="true" id="table" 
				entitySet="Products" initiallyVisibleFields="ProductName"/>
Show 4 Share
10 |10000 characters needed characters left characters exceeded

Hi Radek,

Thanks for your reply.

I created an annotation.xml file and written the code which is previously there in the metadata.xml file. I got the metadata code of northwind service and placed it in the metadata.xml file.

As you specified i added initiallyVisibleFields="ProductID". When i run the application, it is rendering the data from OData.

And when I'm trying to open my annotation.xml through Annotation Modeller it is throwing error like "label_Cannot read property '0' of undefined".

Along with that i have another issue that, if i wants to bind json model to the smart table, in that case in the smart table control for attribute entitySet what value i have to write(i'm using northwind odata service)?

Please say how to resolve it. If you have any example code with you for this type of application please share with me.

Regards,

Sai Ram Dinesh

0
Sai Ram Dinesh Pallapotu

Hello Sai Ram Dinesh,

The V2 metadata version of the Northwind service does not comprise any annotations that could be understood by the Annotation Modeler. Thus you get this error.
You can create a local annotation file via Web IDE context menu: New > Annotation File and import the data from the V4 version http://services.odata.org/V4/OData/OData.svc/$metadata.

But even these data will not be sufficient, as the List report or smart table expects a line item annotation, as documented at the UI5 developer guide.

https://sapui5.hana.ondemand.com/#docs/guide/83c89ccef12f48ab98f6c3811bd025b3.html

https://sapui5.hana.ondemand.com/#docs/api/symbols/sap.ui.comp.smarttable.SmartTable.html#annotations

Best regards,

Stefan

1

Hi Stefan,

Thank you for giving reply and for sharing links. I created the annotations.xml file but when I'm trying to open my annotation.xml through Annotation Modeller it is throwing error like "label_Cannot read property '0' of undefined".

Along with that i have another issue that, if i wants to bind json model to the smart table, in that case in the smart table control for attribute entitySet what value i have to write(i'm using northwind odata service)?

Please say how to resolve it. If you have any example code with you for this type of application please share with me.

Regards,

Sai Ram Dinesh.

0

Create local annotation file and then in annotation modeller add "UI.LineItem" to define initially visible columns.

<Annotation Term="UI.LineItem">
	<Collection>
		<Record Type="UI.DataField">
			<PropertyValue Property="Label" String="Product"/>
			<PropertyValue Property="Value" Path="ProductID"/>
		</Record>
	</Collection>
</Annotation>


Regards,

Anete

1
Stefan Schreck
Dec 22, 2016 at 02:47 PM
1

Hello Sai Ram Dinesh,

Anete has described a workaround by using the code editor. Of course this is a valid workaround.
But I'm glad to inform you that we meanwhile fixed the bug at the Annotation Editor too: it now looks for the entityContainer through all schemas. This fix should already be present in the WebIDE.

Best regards,

Stefan

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Stefan,

Thank you so much for informing about this :). I tried in WebIDE and I'm able to do code annotation file using Annotation Modeler.

I have another issue please see following link.

https://answers.sap.com/questions/90310/index.html

In above I have used OData service and able to work with smart table and Annotation Modeler but now I have to use the JSONModel. In this case please suggest me how to use smart table and Annotation Modeler (or how to write annotation.xl manually) to use JSONModel in my application.

Regards,
Sai Ram Dinesh Pallapotu

0
Basavaraja Goudar Feb 15, 2017 at 04:49 PM
0

Hi,

I have a little different requirement, my odata version is V2 and service is created without vocabulary so no annotation are part of odata service metadata.

my question is

1. Can I use create a local annotation to have intial fields, value list so on with smart tabel

2. then data will come from odata

so data to smart table is from odata service, metadata is on local can this combination work for smart table? if yes please provide steps for the same.

Thank you,

BG

Share
10 |10000 characters needed characters left characters exceeded
Stefan Schreck
Mar 13, 2017 at 08:44 AM
0

Hello Basavaraja,

If you plan to use the smart table, you indeed need annotations - being local or coming from any backend system.
You can use a local annotation file in this case (at least as long as you are not working on SAP applications, then you would have to consider more constraints with regards to layering and delivery).
Note the option of the WebIDE to create a local annotation via the context menu New > Annotation File.

But in any case these annotation files MUST refer to a vocabulary, the references must be part of the annotation edmx.
If you follow the proposed way with the context menu, a template will be applied that leads to an annotation file comprising the standard references.

Share
10 |10000 characters needed characters left characters exceeded