Search code examples
sapui5sap-basisnetweaver

How to define the SAP mandant/client number in an SAPUI5 application running inside Eclipse WebApp preview?


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.


Solution

  • 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)