We have an oDataService that receives a deep entity and with this information it creates a sales order in the SAP backend.
Now the oDataService works fine but sometimes we have a strange behavior: The oDataService is called two times of the same request. The result is, when i want to create a sales order, it creates two identical sales orders with different order id's. The creation time of the orders have a difference of 4 seconds, so it happens in a very short time period.
So my question is: When I call an oDataService once, why does it call the services two times?
I have also build security mechanism in the Fiori app and also in the SAP Backend to prevent the user to send multiple request within a minute. But it does not matter because i belive that the request is not send multiple times by the user. It seems that this happens automatically.
Btw. this also happens when we want to debug an incoming request from the Fiori app, in the SAP backend ABAP code. While we debug another window pops up with the starting breakpoint.
Here is my code where i call the request:
getServiceModel: function (serviceName, oDefaultUpdateMethod) {
var oModel = new ODataModel(this.sBaseUrl + serviceName + "/", {
serviceUrlParams: {
"sap-client": this.sClient
},
defaultUpdateMethod: oDefaultUpdateMethod
? oDefaultUpdateMethod
: sap.ui.model.odata.UpdateMethod.Put
});
oModel.setDefaultCountMode(sap.ui.model.odata.CountMode.None);
return oModel;
}
execCreateRequest: function (serviceName, entitySet, entity) {
if (this.bDevMode) {
return this.oDataDev.execCUDRequest(
this.sBaseUrl + serviceName + "/",
"POST",
entitySet.replace("/", ""),
entity
);
}
return new Promise(
function (resolve, reject) {
var oModel = this.getServiceModel(serviceName);
oModel.attachMetadataFailed(
function (oError) {
reject(oError);
}.bind(this)
);
oModel.attachRequestFailed(
function (oError) {
reject(oError);
}.bind(this)
);
oModel.create(entitySet, entity, {
success: function (response) {
resolve(response);
}.bind(this),
error: function (oError) {
reject(oError);
}.bind(this)
});
}.bind(this)
);
},
Any help is appreciated, thank you