on 04-09-2019 9:31 AM
Hello Experts,
I am facing weird issue, I am trying to use Batch operation for Update in SAPUI5 V2 Odata model. I am using below code to achieve this -
oModel.setDefaultBindingMode(sap.ui.model.BindingMode.TwoWay);
oModel.setUseBatch(true);
oModel.setDeferredGroups(["foo"]);
var mParameters = {
groupId: "foo",
success: function(odata) { },
error: function(odata) { } };
//collected all the rows into BatchChanges
for (var m = 0; m < BatchChanges.length; m++) {
oModel.update("/EntitySet(key='" + BatchChanges[m].key + "')", BatchChanges[m], mParameters);
}
oModel.submitChanges(mParameters);
With above code, if there is no update error in any row, I am getting proper response but if any row update fails, I am not getting all the response, I am getting response of failure only.
To understand completely, I am providing below request & response for both the cases -
Request payload when there is error in one changeset-
--batch_f637-631d-aeed
Content-Type: multipart/mixed; boundary=changeset_3c85-7b07-55c9
--changeset_3c85-7b07-55c9
Content-Type: application/http
Content-Transfer-Encoding: binary
MERGE EntitySet(key='XXXXXX') HTTP/1.1
sap-contextid-accept: header
Accept: application/json
Accept-Language: en
DataServiceVersion: 2.0
MaxDataServiceVersion: 2.0
sap-cancel-on-close: true
Content-Type: application/json
Content-Length: 195
<My row 1 data - which don't have any error>
--changeset_3c85-7b07-55c9
Content-Type: application/http
Content-Transfer-Encoding: binary
MERGE EntitySet(key='YYYYY') HTTP/1.1
sap-contextid-accept: header
Accept: application/json
Accept-Language: en
DataServiceVersion: 2.0
MaxDataServiceVersion: 2.0
sap-cancel-on-close: true
Content-Type: application/json
Content-Length: 195
<My row 2 data - which have any error e.g. Key YYYYY not available in table>
--changeset_3c85-7b07-55c9--
--batch_f637-631d-aeed--
Response for above request (when there is error in one changeset) - clearly I am not getting success response for the row which succeeds.
--4575CB054C5C353865B3B3115238F2640
Content-Type: application/http
Content-Length: 894
content-transfer-encoding: binary
HTTP/1.1 400 Bad Request
Content-Type: application/json;charset=utf-8
Content-Length: 774
dataserviceversion: 1.0
{"error":{"code":"ZEWM/002","message":{"lang":"en","value":"Invalid Key."},"innererror":{"application":{"component_id":"","service_namespace":"/SAP/","service_id":"Test_SRV","service_version":"0001"},"transactionid":"4A641AE4AE290000E005C6BE87770342","timestamp":"","Error_Resolution":{"SAP_Transaction":"","SAP_Note":"See SAP Note 1797736 for error analysis (https://service.sap.com/sap/support/notes/1797736)","Batch_SAP_Note":"See SAP Note 1869434 for details about working with $batch (https://service.sap.com/sap/support/notes/1869434)"},"errordetails":[{"code":"ZXXX/002","message":"Invalid Key.","propertyref":"","severity":"error","target":""},{"code":"/IWBEP/CX_SD_GEN_DPC_BUSINS","message":"Invalid Key.","propertyref":"","severity":"error","target":""}]}}}
--4575CB054C5C353865B3B3115238F2640--
But if both rows are proper with no error, I am getting below valid response -
--2CF0A29AD45ACBEAEC7EF1848F06E9010
Content-Type: multipart/mixed; boundary=2CF0A29AD45ACBEAEC7EF1848F06E9011
Content-Length: 437
--2CF0A29AD45ACBEAEC7EF1848F06E9011
Content-Type: application/http
Content-Length: 71
content-transfer-encoding: binary
HTTP/1.1 204 No Content
Content-Length: 0
dataserviceversion: 2.0
--2CF0A29AD45ACBEAEC7EF1848F06E9011
Content-Type: application/http
Content-Length: 71
content-transfer-encoding: binary
HTTP/1.1 204 No Content
Content-Length: 0
dataserviceversion: 2.0
--2CF0A29AD45ACBEAEC7EF1848F06E9011--
--2CF0A29AD45ACBEAEC7EF1848F06E9010--
As you can see, I am not getting proper response incase any row update fails, kindly help me in the resolution of this issue.
Regards,
Ravi
Hello Experts,
Do we have any way when there is error in one changeset, only that gives error response & other executes with success message?
Thanks
Ravi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
that is how it works,
none or all
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
94 | |
11 | |
11 | |
10 | |
9 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.