on ‎2017 May 17 1:35 PM
I have got a table bound to an odata model as in the picture:

I have deferred changes to that entity:
this._oModel.setDeferredGroups(["EquiChars"]);
this._oModel.setChangeGroups({ "EquipmentCharacteristics": {
groupId: "EquiChars",
single: true } });
And when the user clicks "Save" I want to post changes to the backend:
this._oModel.submitChanges({groupId: "EquiChars",
merge: false,
success: function(oResponse){},
error: function(oError) {} });
So what may happen that the 1st entry changed successfully and the 2nd one failed hence I would like to show an error log to the user e.g.
Equipment 10001654 successfully updated.
Equipment 1001693 failed top update + message from the backend.
But from the "oResponse" I can only identify error messages for the entries that failed.
And I can't identify entries that were successfull as it is not returning any key/data of the successfully updated entry.
Any suggestions on how to identify which postings failed/succeeded?
Request clarification before answering.
Radek,
As per OData standards, response body of an 'Update' is empty and successful response code is 204. So UI has to just look for this code and assume that update is successful.
If you really want success or warning messages, you can send them back as response headers by doing as below.
DATA lo_message_container TYPE REF TO /iwbep/if_message_container.
" get message container object
lo_message_container = me->/iwbep/if_mgw_core_srv_runtime~mo_context->get_message_container( ). lo_message_container->add_message(
iv_msg_type = /iwbep/cl_cos_logger=>warning
iv_msg_id = /iwbep/cx_tea_business=>team_id_out_of_range-msgid
iv_msg_number = /iwbep/cx_tea_business=>team_id_out_of_range-msgno
iv_add_to_response_header = abap_true
).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
oData contains the parsed response data as a Javascript object. The batch response is in the __batchResponses property which may contain further __changeResponses in an array depending on the amount of changes and change sets of the actual batch request which was sent to the backend. The changeResponses contain the actual response of that change set in the response property. For each change set there is also a __changeResponse property.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
check this below code, it should return an array of batch responses, it may help.
oResponse.__batchResponses
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That' what I am doing in the backend:
ls_changeset_response-operation_no = ls_changeset_request-operation_no.
copy_data_to_ref(
EXPORTING
is_data = ls_equipmentcharacteristics
CHANGING
cr_data = ls_changeset_response-entity_data ).
INSERT ls_changeset_response INTO TABLE ct_changeset_response.
| User | Count |
|---|---|
| 11 | |
| 7 | |
| 6 | |
| 5 | |
| 4 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.