cancel
Showing results for 
Search instead for 
Did you mean: 

manifest datasource service uri sap-client dynamic

adrian_zguri
Explorer
4,038

Hello

Premise:

I am trying to build a web site with WebIde that will be deployed for 2 different sap clients.

The two clients have data on the same sap server, but they have 2 different clients (300 and 500).

I have created an OData service http://myhosturl.de/sap/opu/odata/myservice with the SAP NetWeaver Gateway Service Builder on the server with client 100 and registered my service on the clients 300 and 500.

I am able to get the data from the clients if append the string "?sap-client=500" to the service URL but I would like to have it dynamic, based on some javascript variable.

The datasource part of my manifest.json is as follows:


"dataSources": {

     "mainService": {

         "uri": "/destinations/mydestination/sap/opu/odata/myservice/",

         "type": "OData",

         "settings": {

      "odataVersion": "2.0",

      "localUri" : "localService/metadata.xml"

       }

     }

  }

and the sap.ui5 model is as follows:


"": {

     "dataSource": "mainService",

     "settings": {

       "serviceUrlParams": {

            "sap-client": "500"

         }

     }

}

Is there a way to add the "sap-client" parameter dynamically without having to hardcode the property wih the "serviceUrlParams"?

Thank you for your help.

Adrian

View Entire Topic
adrian_zguri
Explorer

I finally found the ansewer in this link: SAPUI5 SDK - Demo Kit

At the bottom of the page there is written:

"At runtime, the manifest.json content can be accessed from the component via the component metadata"

So I wrote this piece of code on the onInit method of the Component.js:



var oManifestUi5 = this.getMetadata().getManifestEntry("sap.ui5");

oManifestUi5.models[""].settings.serviceUrlParams["sap-client"] = _sapClient;

oManifestUi5.models[""].settings.metadataUrlParams["sap-client"] = _sapClient;

With that I can change the property sap-client at will based on some other configuration

york_chen
Associate
Associate
0 Kudos

It is possible to get this in controller?

junwu
SAP Champion
SAP Champion
0 Kudos

this.getOwnerComponent() then you can access the manifest

0 Kudos

Hi,

I am trying to change the model configuration in the same way. I am able to see the change on console but it is not updating the manifest.json file. Any idea why the changes are not reflected?