cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

SAPUI5 Function import usage

Former Member
0 Likes
1,559

Hello,
My colleague has implemented Function Import which downloads data from a public repository and it works exactly how it should when called in browser

SERVER_NAME/GetProductInfoFromWebservice?N='9206'

returns correct data in XML, for example, product name, but when I'm trying to utilize it in SAPUI5 application

this._oODataModel.callFunction("/GetProductInfoFromWebservice",
"GET", {
"N": "9206"
},
null,
function(oData, oResponse) {
console.debug(oData);
console.debug(oResponse);
},
function(oError) {
console.debug(oError);
}
);

it doesn't do a thing. Nothing shows up on the console.
When I've tried to use read instead of callFunction returned object had only empty fields.

How do I correctly utilize Function Import in cases like this?

View Entire Topic
Fabrice
Active Participant

Hi,

i used the callFuntion like this :

var calledFunction = oModel.callFunction("/MyImportFunction",{
  method : 'GET',
  urlParameters : {
    param1: value1,
    param2: value2
  },
  success : function(oData, response){
    ...
  },
  error : function(){
    ...
  }
});

Note: if the function does not exist, the promise (calledFunction.contextCreated) is rejected so we do not go in the 'success' or 'error' callback from 'callFunction. That is why i add this code after the call:

calledFunction.contextCreated().catch(function(error){
    ...
});

doc: https://sapui5.hana.ondemand.com/#/topic/6c47b2b39db9404582994070ec3d57a2.html#loio6cb8d585ed594ee4b...


i hope it will help you

Regards

Fabrice

Former Member
0 Likes

The problem lied in not writing method, urlParameters, and parenthesis placement.