cancel
Showing results for 
Search instead for 
Did you mean: 

Passing parameters to oData service

former_member518313
Discoverer
0 Kudos

Hi Folks,

We have 2 oData services configured in the destinations, manifest.json and neo-app.json.

Odata Services : First

Second : This service requires a parameter to be sent to the oData and display the relevant data in the view.

Value selected in the first service should be passed as the input parameter to the second service.

We have to write Queries for filtering only required data to be displayed in input fields.

The scenario is :

We have a drop down with certain values retrieved from oData service. If we select a value, the data to that particular value should be displayed in the below input fields. This data is present in another(second) oData service.

Please help me by giving a sample example to this scenario.

Regards,

Aravind.

Accepted Solutions (0)

Answers (2)

Answers (2)

irfan_gokak
Contributor
0 Kudos

Hi,

You can do as following.

// under manifest.json
// ************** under "sap.app" component *******************

"dataSources": {
			"mainService1": {
				"uri": "/yourFirstServicePath/",
				"type": "OData",
				"settings": {
					"odataVersion": "2.0",
					"localUri": "localService/metadata.xml"
				}
			},
			"mainService2": {
				"uri": "/secondServicePath/",
				"type": "OData",
				"settings": {
					"odataVersion": "2.0",
					"localUri": "localService/metadata.xml"
				}
			},

// ************** under "sap.ui5" -> "models" **************************

"": {
				"dataSource": "mainService1",
				"preload": true
			},
			"nw": {
				"dataSource": "mainService2",
				"preload": true
			},

// **************************************************************
// Under neo-app.json specify 2 destinations
{
      "path": "/FirstDestination",
      "target": {
        "type": "destination",
        "name": "northwind"
      },
      "description": "NorthWind"
    },
{
      "path": "/SecondDestination",
      "target": {
        "type": "destination",
        "name": "northwind"
      },
      "description": "NorthWind"
    },

// ******************************************************************
// In controller use below code to get particular model. 
var srvOneModel = this.getView().getModel(); // No name specified because under model also empty
var srvTwoModel = this.getView().getModel("nw"); // Name "nw" is mentioned in for another service under model

// Using these two model call .read to call your paricular entityset from particular odata service.

If this info is useful please mark it answered.

irfan_gokak
Contributor
0 Kudos

Hi Aravind,

Please tell me what error you're getting?

former_member518313
Discoverer
0 Kudos

Hi Irfan,

I want to know how can we implement the above scenario.

I haven't written any code on the above.

Please let me know if you have any idea on implementation.

Regards,

Aravind