Skip to Content
0

Passing parameters to oData service

Nov 27, 2017 at 07:07 AM

35

avatar image

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.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Irfan Gokak Nov 27, 2017 at 08:32 AM
0

Hi Aravind,

Please tell me what error you're getting?

Show 1 Share
10 |10000 characters needed characters left characters exceeded

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

0
Irfan Gokak Nov 27, 2017 at 01:35 PM
0

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.

Share
10 |10000 characters needed characters left characters exceeded