Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8932

Parse OData Error Message returned from Gateway

$
0
0

I've posted this same question in another thread but didn't get any reply due to lack of info.  At that time, it was an issue we didn't need to address yet.  With some free time, I have a code snippet that I can use to illustrate what I'm trying to accomplish.

 

I have a SAPUI5 Model that calls the create method which is sent to SMP 2.3.  SMP 2.3 passes this request to Gateway, where Gateway runs the specific service.  Assuming that the BAPI service executes but there is business logic error like "Record already exist".  The response of Gateway to SMP 2.3 should include this "error message" of "Record already exist".  I can see the Gateway response from SMP 2.3 server logs.  Assuming that the error message is included in the response, I need a way to specifically get that verbose message and alert that to the user.

 

The client is a mobile app using SAPUI5 framework.

 

Code snippet:

 

var model = new sap.ui.model.odata.ODataModel(serviceURL, false, username, password, customHeader, true);

 

assuming that the model instance is successfully created.  Within the use case, I eventually make this call:

 

model.create(SPath, parameterArrays,

 

                              function() {

                                   //this function is the callback if create is actually successful

                                   alert("Record Created");

                              },

 

                              function(error, data) {              

                                   //this function is the callback if the create fails for whatever reason

                                   alert("Create Record failed " + error.message);

                              }

                    );



When the create method fails, I get something like "HTTP Request Failed".  But looking into the Gateway logs, the real failure is a business logic fail; per above it would be something like "Unable to create, record already exist".  This is the verbose message that I am interested in getting.


The "data" parameter in the error function callback when I attempt to alert out it's length comes back as undefined:   alert("Create Record failed " + error.message + "^" + data.length);



So my issue is, how can I get a handle of the response, which is essentially from SMP 2.3 server so that I can loop through this response and select the verbose message.


Any help is truly appreciated.  Thanks.


Viewing all articles
Browse latest Browse all 8932

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>