Skip to Content
Dec 11, 2016 at 12:26 PM

oData: cannot call RFC from backend

458 Views Last edit Dec 14, 2016 at 11:52 AM 3 rev

Hi Experts,

I created a simple function RFC returning a structure BAPIRET2.

I created all the steps (I guess so) in spro, segw. I succeed calling the SAP Gateway Client.

In SEGW, I created an EntitySet: in it, I created the Read mapping (not the Query).

In NWDS 7.50, I create a a ui5 project with javascript view.

I created a simple table or even a Label to print out the returning string from RFC.

I do not get anything back, not even an error.

This is my code in the onInit of the controller:

var oModel = new sap.ui.model.odata.ODataModel("http://server:port/sap/opu/odata/sap/ZTEST2_SRV/HELLO_WORLD1Set('qwqwqw')", true, "user", "password");

var oTable = sap.ui.getCore().byId("MyTable"); 

Nothing returns.

But, if I create a simple html file on my desktop, I do succeed calling the same RFC using ajax:

var auth = btoa('user:password');

$(document).ready(function () {

$('#get-data').click(function () {

$.ajax({ type: "GET", data: '{}', url: "http://server:port/sap/opu/odata/sap/ZTEST2_SRV/HELLO_WORLD1Set('1111')/EMessage",

headers: { "Authorization": "Basic " + auth },

contentType: "application/json; charset=utf-8",

dataType: "json",

success: function(data) { alert(">>" + JSON.stringify(data)); },

error: function(data) { alert(">>>>>" + JSON.stringify(data)); }, });



Can someone please help?

Thanks in advance.