Skip to Content
0

Consume Odata service in a Ui5 table in Eclipse Application

Mar 02, 2017 at 12:32 AM

117

avatar image

Hello Ui5 Experts,

I have started learning Ui5 and I am struck with the basic process.

I have an Ui5 application running on abap server. I have created an odata service and it returns the values when its run as a url. But when I try to populate the table with just 1 data it is not displaying. I am not sure whether its getting the data to the table or not. I have tried all the methods given in the forum and tried googling in different formats. But I am not getting the value in my table. I have attached my code below.

Controller Code:

var domainString = "document.domain";

domainstring = "*.com";

'Access-Control-Allow-Origin: *.local.com';

'Access-Control-Allow-Headers: X-KEY';

var oModel = new sap.ui.model.odata.ODataModel("proxy/http/serverdetails/sap/opu/odata/sap/Z_DS_EMP_PORTAL_SRV/",true,"uname","pwd");

sap.ui.getCore().setModel(oModel);

var oTable = new sap.ui.table.Table({ editable: false, });

oTable.setModel(oModel);

oTable.addColumn(new sap.ui.table.Column({ label: new sap.ui.commons.Label({text: "Name"}),

template: new sap.ui.commons.TextField().bindProperty("value", "Name"),

editable: false, sortProperty: "Name" }));

oTable.addColumn(new sap.ui.table.Column({ label: new sap.ui.commons.Label({text: "Bname"}),

template: new sap.ui.commons.TextField().bindProperty("value", "Bname"),

sortProperty: "Bname", editable: false, }));

oTable.addColumn(new sap.ui.table.Column({ label: new sap.ui.commons.Label({text: "Telephone"}),

template: new sap.ui.commons.TextField().bindProperty("value", "Telephone"),

sortProperty: "Telephone", editable: false, }));

oTable.addColumn(new sap.ui.table.Column({ label: new sap.ui.commons.Label({text: "Emailid"}),

template: new sap.ui.commons.TextField().bindProperty("value", "Emailid"),

sortProperty: "Emailid", editable: false, }));

oTable.bindRows({path : "/ZEMP_LOGINSet"},null,["$filter=Bname eq 'DHIVYAS' and Pwd eq '00000000000000000000000000000000'"]);

oMasterShell.setContent(oTable);

Below is My URL result

I have made the 'proxy/http' change recently after seeing a website still it doesnt work.Initially I had "http://serverdetails"

I tried to debug in IE when I keep the debbugger in oModel it says 'odata' is undefined

Final Screen:

Sorry if I had asked very simple one. But i have been banging my head with this issue for so many days.

I hope i am clear on my question. Please help me where I am wrong.

Thanks in Advance

Dhivya

3.png (11.0 kB)
4.png (5.5 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Jun Wu Mar 02, 2017 at 01:36 AM
0

very complex for junior.

can u just deploy to gateway server to run. it will be very simple.

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

Thanks for the reply Jun Wu,

My system doesn't show the option for "Gateway Client". But it has already been registered.

gw.png (56.0 kB)
0
Dhivya Karthikeyan

is it related?

I am asking u to deploy your app to abap server to run

0

Sorry for the late response. I deployed my app on the abap server only. And try to "Run on ABAP server"

0

then?????????????

0

Divya, just go to SICF tcode and find the service name (same name of your project name while uploading) and right click on it and click on Test..... will open your application in the browser :)

0
Seungchul Yang Mar 16, 2017 at 01:37 AM
0

I think you already read this guide

https://sapui5.hana.ondemand.com/sdk/index.html#docs/guide/510d6eeed849447fbf497cfa5b640514.html

If it doesn't work, you can disable web security option for Chrome.

Add arguments to Chrome shortcut.

".....chrome.exe" --user-agent --disable-web-security

Share
10 |10000 characters needed characters left characters exceeded