2

With the Eclipse development tools for SAPUI5 it is possible to run a SAPUI5 app in WebApp preview mode. It's working fine expect one point.

The client data used in OData service is always "100" by default. I assume the used client is the one used for repository setup.

But for testing I have to use a different client (200) because of maintained test data.

Since SAPUI5 1.26.9 and corresponding development tools it seems to work, defining a default client at SAP NetWeaver Gateway but after an upgrade to 1.28.x most of the time client 100 is used.

Now I am searching the documentation for that problem but can't find anything. One problem of course would be to that the search term "client" will not help at all.

I would also aviod to hard code any client number somewhere because at the real system the logged in client will be used automatically.

But in the WebApp preview I will not be asked for a client.

Maybe this is the wrong place to ask this question? In that case I will delete it.

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
user3783327
  • 616
  • 8
  • 30
  • 60

3 Answers3

2

Can you have a parameter in the URL and link that to retrieving your serviceUrl?
Maybe you can have a URL parameter and based on that you can 2 service URL's one with hard-coded value of client 200 and other without anything. You can retrieve the parameter:

jQuery.sap.getUriParameters().get("test-mode") === "true";

To hard code the client in OData service definition:

var sUrl = "proxy/protocol/server:port/pathToService?sap-client=600";
var oModel = new sap.ui.model.odata.ODataModel(sUrl,true)
ryanyuyu
  • 6,366
  • 10
  • 48
  • 53
Veeraraghavan N
  • 839
  • 1
  • 10
  • 19
  • Is there a way to hard code the client in OData service definition? Have not found how? – user3783327 Aug 24 '15 at 14:53
  • var sUrl = "proxy/protocol/server:port/pathToService?sap-client=600"; var oModel = new sap.ui.model.odata.ODataModel(sUrl,true); ****i am using a default proxy servlet to get over the Cross Origin Issue**** – Veeraraghavan N Aug 25 '15 at 08:26
2

You could use the sap-client GET-parameter. This one will be passed to your application automatically when you used the SAP Portal or SAPGUI.

ODataModel passes it to data-service with its own.

0

When you call your model object, you can pass some header variables to 'point' to the right sap client.

    // Set the client header variable
    var oHeaders = {'sap-client': '120'};
    var bCSRF = "true";
    var oModel = sap.ui.model.odata.ODataModel(serviceURL, true, "user", "pass", oHeaders, bCSRF, false, false, "", false);
    sap.ui.getCore().getModel(oModel, 'gAppModel')

You can test which header variables you need using a REST client like Postman.

The details of the OData constructor can be found in the API - UI5 OData Model

warrenei
  • 126
  • 3