on 01-26-2016 2:39 PM
Dear SCN Members,
I'm trying to submit the changes by the user and catch errors, before calling a function import doing the save in the ABAP OData service. The success callback is executed always, however the submit request fails, due an error raised by the GateWay itself, and not by my application code.
In my view controller, first I submit the changes, and it results in a successful calback of onSaveAfterSubmit
// Submitting pending changes
onSave: function() {
this._oHelper.createBusyDialog();
if (this._oModel.hasPendingChanges()) {
this._oHelper.submitAllChangesCE(
this.onSaveAfterSubmit.bind(this),
this.onSaveSubmitFailed.bind(this)
);
}
},
onSaveSubmitFailed: function(oError){
var oErrorInt = oError;
},
onSaveAfterSubmit: function(oData,oReponse) {
this._oHelper.saveRequest(
this._oView.getModel().getProperty(this._sItemPath).Id,
jQuery.proxy(this._requestSaveSuccess, this)
);
},
},
// Submitting pending changes to entities registered in deferred batch groups
submitAllChangesCE: function(fnSuccess, fnError) {
this._oDataModel.submitChanges({
success: fnSuccess,
error: fnError
});
},
this._oModel.attachRequestFailed(null, cust.ecc.md.vendor.requester.util.messages.showErrorMessage);
Instead of function onSaveSubmitFailed, always the cust.ecc.md.vendor.requester.util.messages.showErrorMessage is called, whenever the length of the user input is longer than the maximum length of the DDIC field behind. This exception is raised by the GW itself, and not by my application:
HTTP request failed400,
Bad Request,{"error":{"code":"/IWCOR/CX_DS_EDM_FACET_ERROR/005056A509B11ED1BDCCCC5E8168819D","message":{"lang":"en","value":"Value 'SOGEFRPP ' violates facet information 'maxlength=11'"}
What I do not understand, that why is onSaveAfterSubmit called at all, in the case the request fails, together with showErrorMessage.
I want to prevent the Save on a nice way in this case, because at the moment the success callback is exeuted doing the Save in the backend, however the changes could not be submitted, and get lost.
Any idea, how to do that nicely ?
Should I set a boolean in the cust.ecc.md.vendor.requester.util.messages.showErrorMessage ? This would be not really nice, at least in my opinion , there should be a better way or concept to manage this.
Thank you, Attila
You can look at the oResponse.statusCode to determine if the execution was successful. The error function is when the connection request fails.
Regards,
Jamie
SAP - Technology RIG
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Jamie, nice closing of my working hours
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.