cancel
Showing results for 
Search instead for 
Did you mean: 

oData Service Binding from Function Module

Former Member
0 Kudos

Hi,

I have a requirement where oData service is consuming a Function Module (FM). This FM is having a IMPORT, a EXPORT parameter along with a Table.

Scenario is, in UI5 application user will provide input in a input box and click on a button.

On click, it should fetch the export parameter and Table from the oData service.

In UI5 application, I am facing issues while sending input to oData and get the required items.

If I do hard-coding the import paramter of FM in oData service, I am getting the table values in entityset.

Any pointers to good way to achieve this will be helpful.

Thanks,

Saurabh

Accepted Solutions (1)

Accepted Solutions (1)

former_member227918
Active Contributor

how you are passing parameter from ui ? post your code.....

you can give a try

"/entityset(param1='val1', param2='val2')"

or

var aFilters = [];
aFilters.push(new sap.ui.model.Filter("param1", sap.ui.model.FilterOperator.EQ, "val1") );
aFilters.push(new sap.ui.model.Filter("param2", sap.ui.model.FilterOperator.EQ, "val2") );

oModel1.read("/entityset", {
    filters : aFilters,

...........
Former Member
0 Kudos

Thanks Akhilesh for response.

To add here, I created a function import in oData and calling that in UI5 application.

Function import is returning the correct results where tested from Gateway client.

Now in UI5 application, binding of correct results is not happening. I need to fetch the items and display in a table.

Below is code from controller.js :-

oModel.callFunction("/TestFuncImport", {
  method:"GET",
  urlParameters: oUrlParams,
  success: jQuery.proxy(this.successCall, this),
  error: jQuery.proxy(this.errorCall,this)
});
},

successCall: function(oData) {
	var oView = this.getView();
	var oTable = oView.byId("idTable");
			  
	var oModel = new sap.ui.model.json.JSONModel();
	oModel.setData(oData);			  
	oTable.setModel(oModel, "ZResultSet");	// ZResultSet is entity set in oData service		
	oTable.getBinding("items");
},

But in above case table is always blank.

Can you please suggest what's going wrong here?

former_member227918
Active Contributor
0 Kudos

follow oData now,

successCall: function(oData) {
	var oView = this.getView();
	var oTable = oView.byId("idTable");
			  
	var oModel = new sap.ui.model.json.JSONModel();
	oModel.setData(oData);			  
	oTable.setModel(oModel);
 
//for example oData is:
oData = { "ZResultSet": [{ "id": "1", "name": "AAAA" }, { "id": "2", "name": "BBBB" }, { "id": "3", "name": "CCCC" }] };

},

//and in table declaration as below:

<Table id="idTable" items="{path: '/ZResultSet'}" >

if you dont have items property in table declaration then you need to bind table using aggregation. if above code didnt help you, paste your table code here

Former Member
0 Kudos

Thank you Akhilesh, it worked 🙂

As I mentioned earlier, I have an EXPORT parameter also in FM, how we can capture that in oData service?

Is it possible via function import? It needs to be captured in a single text field in UI5 app (not in table).

Thanks,

Saurabh

former_member227918
Active Contributor
0 Kudos

Please accept this conversation to mark it resolved!

As I mentioned in my first response you can pass parameter in odata service, and in urlparameters you can pass parameters from Ui while calling function import.

Answers (1)

Answers (1)

Former Member
0 Kudos

I got it Akhilesh, thanks for your inputs.

Regards,

Saurabh