-1

I need a manual OData call from SAPUI5 to my SAP Gateway (without data binding).

For that, I'm using the following code:

oModel.read("/ZTestSet"),  
    null,null,false, function(oData, oResponse){
       alert("success");
    },
    function(oError ){
       alert("error");
} 

I've debugged it on the SAP system. I received the call and fill the et_entityset with the required data.

The problem is, that no function will be triggered as callback. Neither success nor error (I can't find any error on the gateway or someone else).

Response in Browser's Developer Tools:

HEADERS:
     
Request Method:GET
Status Code:200 OK
     
RESPONSE HEADERS:
cache-control:no-store, no-cache
Connection:keep-alive
content-encoding:gzip
Content-Length:827
Content-Type:application/atom+xml; charset=utf-8
dataserviceversion:2.0
Date:Tue, 05 Apr 2016 12:08:34 GMT
Proxy-Connection:keep-alive
sap-metadata-last-modified:Tue, 05 Apr 2016 10:06:59 GMT

REQUEST HEADERS:
Accept:application/atom+xml,application/atomsvc+xml,application/xml
Accept-Encoding:gzip, deflate, sdch
Accept-Language:en-US
Cache-Control:no-cache
DataServiceVersion:2.0

RESPONSE:
<feed xmlns="http://www.w3.org/2005/Atom" 
 xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xml:base="<<ADDRESS>>">
  <id><<ADDRESS>></id>
  <title type="text"><<FUNCTION>></title>
  <updated>2016-04-05T12:08:34Z</updated>
  <author>
    <name />
  </author>
  <<LIST OF ENTRIES>>
</feed>

Looks like a successful call.

Boghyon Hoffmann
  • 17,103
  • 12
  • 72
  • 170
alexander-fire
  • 1,082
  • 4
  • 27
  • 52

2 Answers2

0

place the below debuger line in both the success and error calls and see if it triggers in the browser. oModel.read is an asynchronous call meaning it doesn't wait for the response and triggers the success or error method only after it receives either of the response from the server. So if you are waiting then it might look like nothing's happening.

              debugger;
Ajay Reddy
  • 1,475
  • 1
  • 16
  • 20
  • It´s an asynchronous call, yes i know. I also tried it with the ´debugger´ statement, but even so it will not be triggered after several minutes. – alexander-fire Apr 06 '16 at 06:09
0

What a silly mistake.

I closed the parenthesis after the URL. It should be closed naturally after the last parameter. In my case after the error-function.

Right code:

oModel.read("/ZTestSet", null, null, false, function(oData, oResponse) {
  alert("success");
}, function(oError){
  alert("error");
});
Boghyon Hoffmann
  • 17,103
  • 12
  • 72
  • 170
alexander-fire
  • 1,082
  • 4
  • 27
  • 52