cancel
Showing results for 
Search instead for 
Did you mean: 

Can't access SAP sample gateway services data

0 Kudos

Hello Everybody,

I am trying to connect my UI5 application with SAP sample oData Gateway Services. But unfortunately it doesn't Show any data in the table of my UI5 application. oData Gateway URL and application code snippets are the following.

Sample Gateway Services: https://sapes1.sapdevcenter.com/sap/opu/odata/sap/ZGWSAMPLE_SRV/$metadata

oData Entity values:

-<EntityType sap:content-version="1" Name="BusinessPartner">

-<Key>

<PropertyRef Name="BusinessPartnerID"/>

</Key>

<Property Name="BusinessPartnerID" sap:updatable="false" sap:label="GeschPartnID" MaxLength="10" Nullable="false" Type="Edm.String" sap:creatable="false"/>

<Property Name="BpRole" sap:label="GeschPartnRolle" MaxLength="3" Type="Edm.String" sap:filterable="false"/>

<Property Name="EmailAddress" sap:label="E-Mail-Adresse" MaxLength="255" Type="Edm.String" sap:semantics="email" sap:filterable="false"/>

<Property Name="CompanyName" sap:label="Firmenname" MaxLength="80" Type="Edm.String"/>

Application code snippets:

createContent : function(oController) {

 

  var oModel = new sap.ui.model.odata.ODataModel("https://sapes1.sapdevcenter.com/sap/opu/odata/sap/ZGWSAMPLE_SRV");

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

  var oTable = new sap.ui.table.Table({

  editable: false

  });

  oTable.addColumn(new sap.ui.table.Column({

  label: new sap.ui.commons.Label({text: "ID"}),

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

  sortProperty: "BusinessPartnerID"

  }));

  

  oTable.addColumn(new sap.ui.table.Column({

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

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

  sortProperty: "CompanyName"

  }));

  

  oTable.addColumn(new sap.ui.table.Column({

  label: new sap.ui.commons.Label({text: "E-mail"}),

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

  sortProperty: "EmailAddress"

  }));

  

     oTable.setModel(oModel);

     oTable.bindRows("/BusinessPartner");

     oTable.placeAt("content");

  }

Please point me out where is the problem.

Thank you very much.

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

I have solved the problem. Actually we have to add a prefix 'proxy' before oData URI string like.

"proxy/https/sapes1.sapdevcenter.com/sap/opu/odata/sap/ZCD204_EPM_DEMO_SRV"

If the application has to run on ABAP server then we can write a normal string like.

"https://sapes1.sapdevcenter.com/sap/opu/odata/sap/ZCD204_EPM_DEMO_SRV"

Answers (1)

Answers (1)

ChandraMahajan
Active Contributor
0 Kudos

Because you need to bind the Entity Collection.

Check https://sapes1.sapdevcenter.com/sap/opu/odata/sap/ZGWSAMPLE_SRV/BusinessPartnerCollection

below line should be,

   oTable.bindRows("/BusinessPartnerCollection");


Regards,

Chandra

0 Kudos

Thank you for your response but sorry it also doesn't work with "/BusinessPartnerCollection"

I also tried to add the Username and password in the ODataModel constructor but it is not working too.

ChandraMahajan
Active Contributor
0 Kudos

Open the application on chrome browser and debug (press F12 to launch chrome developer tool). check for the errors. also check my blog and try to rectify errors as mentioned in the blog.

Regards,

Chandra