Skip to Content
0

oData Service Binding from Function Module

May 23, 2017 at 11:10 PM

156

avatar image
Former Member

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

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

2 Answers

Best Answer
Akhilesh Upadhyay May 24, 2017 at 08:06 AM
1

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,

...........
Show 4 Share
10 |10000 characters needed characters left characters exceeded
Former Member

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?

0

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

0
Former Member

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

0

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.

0
avatar image
Former Member May 26, 2017 at 06:11 PM
0

I got it Akhilesh, thanks for your inputs.

Regards,

Saurabh

Share
10 |10000 characters needed characters left characters exceeded