cancel
Showing results for 
Search instead for 
Did you mean: 

manifest datasource service uri sap-client dynamic

adrian_zguri
Explorer

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

Accepted Solutions (1)

Accepted Solutions (1)

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
Discoverer
0 Kudos

It is possible to get this in controller?

junwu
Active Contributor
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?

Answers (1)

Answers (1)

adrian_zguri
Explorer
0 Kudos

Hello Shivam,

The manifest.json file doesn't get changed. That is a configuration file which is read and saved in an internal model. What I change are the values of this internal model.

Adrian

former_member626660
Participant
0 Kudos

Hi Adrian,

Can we change the manifest file's query parameters at runtime in the controller file as suggested..? Will that trigger the manifest call again and load the data in the specified language?

Regards

Imtiaz N

var str = this.getOwnerComponent().getManifestObject()._oManifestBaseUri._string;
//sample url
/str = https://xyz/manifest.json?sap-language=EN
var str1 = str.split("?")[0] + "?sap-language=" + language.toLocaleUpperCase();
//expected url
//str1 = https://xyz/manifest.json?sap-language=DE
this.getOwnerComponent().getManifestObject()._oManifestBaseUri._string = str1;