on 2016 May 11 1:15 PM
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
Request clarification before answering.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
12 | |
9 | |
8 | |
8 | |
5 | |
4 | |
4 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.