Hi all,
I'm working with ODATA for a while now and finally tried to get the batch mode running.
Everything works fine so far, but I'm struggling with the message handling.
I'd like to hand back messages from backend to frontend, either if the (update) request was successful or failed.
I redefined the changeset_begin method and set
cv_defer_mode = abap_true.
to jump into the changeset_process method.
In the changeset_process method I added the following code:
METHOD /iwbep/if_mgw_appl_srv_runtime~changeset_process. DATA: ls_changeset_request TYPE /iwbep/if_mgw_appl_types=>ty_s_changeset_request, ls_changeset_req_parent TYPE /iwbep/if_mgw_appl_types=>ty_s_changeset_request, lo_create_context TYPE REF TO /iwbep/if_mgw_req_entity_c, lv_entity_type TYPE string, ls_changeset_response TYPE /iwbep/if_mgw_appl_types=>ty_s_changeset_response, ls_changeset_resp_parent TYPE /iwbep/if_mgw_appl_types=>ty_s_changeset_response, ls_tbl_bndl TYPE zcl_zfvr_ui5_mpc=>ts_tbl_bndl, lt_tbl_bndl TYPE zcl_zfvr_ui5_mpc=>tt_tbl_bndl, lv_error_entity TYPE string. FIELD-SYMBOLS: <ls_header> TYPE zcl_zfvr_ui5_mpc=>ts_tbl_bndl. LOOP AT it_changeset_request INTO ls_changeset_request. lo_create_context ?= ls_changeset_request-request_context. lv_entity_type = lo_create_context->get_entity_type_name( ). *--------------------------------------------------------------------* "! CREATE CASE ls_changeset_request-operation_type. WHEN /iwbep/if_mgw_appl_types=>gcs_operation_type-create_entity. * create (HTTP POST) CASE lv_entity_type. WHEN 'TBL_BNDL'. ls_changeset_request-entry_provider->read_entry_data( IMPORTING es_data = ls_tbl_bndl ). ENDCASE. ENDCASE. ENDLOOP. DATA ls_messages LIKE LINE OF lt_messages. DATA lt_messages TYPE bapiret2_t. ls_messages-type = 'E'. ls_messages-id = '1'. ls_messages-message = 'custom message'. ls_messages-log_no = ''. ls_messages-log_msg_no = ''. ls_messages-message_v1 = 'E_Var1'. ls_messages-message_v2 = 'E_Var2'. ls_messages-message_v3 = 'E_Var3'. ls_messages-message_v4 = 'E_Var4'. ls_messages-parameter = ''. ls_messages-row = ''.DATA lo_container TYPE REF TO /iwbep/if_message_container. lo_container = me->mo_context->get_message_container( ).lo_container->add_message( iv_msg_type = ls_messgaes-type iv_msg_id = ls_messgaes-id iv_msg_number = ls_messgaes-number iv_msg_text = ls-messages-mesage iv_is_leading_message = abap_true iv_add_to_response_header = abap_true). ENDMETHOD.
I tried to get the messages in the UI5-frontend via
oModel.update("/TBL_BNDLSet('1')", Object , {groupId: "editGroup"}); oModel.submitChanges({ groupId: "editGroup", success: function(data, response){ console.log(response.headers["sap-messages"]); } });
While not using batch, espacially not using the changeset_process method but using the TBL_BNDLSET_UPDATE_ENTITY Method this worked fine.
But with batch processing, I can't find any custom messages in the response.
I tried to raise exceptions and finde those messages, but couldn't find them either.
The weired thing is, the debugger does not even jump into the changeset_end method (which is redefined).
How does the message handling with batch works? Any ideas or suggestions?
The reason why I want to use the changeset_process method is, because I want to push mutliple entries to the backend and process them in the database at once.
Many thanks and best regards
Moritz