cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

submitChanges callback

Former Member
0 Likes
3,388

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?

Accepted Solutions (1)

Accepted Solutions (1)

kammaje_cis
SAP Mentor
SAP Mentor

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 
     ).
Former Member
0 Likes

Thanks Krishna. That's what I was suspecting but was looking for someone to assure me there won't be a callback from update method.

kammaje_cis
SAP Mentor
SAP Mentor
0 Likes

Radek, not sure if I misled you. In UI5 there will always be a response, but no response body in case of a succesful update.

Former Member
0 Likes

Yep I understand that and that's exactly what I see in the response.

DanielWhite
Product and Topic Expert
Product and Topic Expert
0 Likes
I am getting a 204 when posting using submitchanges. this returns a 204, but it is not caught by success or error handlers. How to I handle this?

Answers (2)

Answers (2)

maheshpalavalli
Active Contributor
0 Likes
Like Akhilesh Suggested, pls check the oResponse data as mentioned in the standard documentation.

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.

former_member227918
Active Contributor
0 Likes

check this below code, it should return an array of batch responses, it may help.

oResponse.__batchResponses

Former Member
0 Likes

I am aware of that but that is the problem that I don't get to see anything meaningful in the response. See the screen below:

maheshpalavalli
Active Contributor
0 Likes

i hope in the backend you are passing the data back to ui in the changing parameter ct_changeset_response.

Best Regards,

Mahesh

Former Member
0 Likes

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.
former_member227918
Active Contributor
0 Likes

i think from backend itself you can pass batch info/message in the "body" property, but i dont know how.