Sunday, May 31, 2026

OData 4: Step for Update

  • The UPDATE operation comes into play whenever an existing entry resource needs to be changed.
  • Similar to the Read/Query methods, you need to redefine this method in the DPC extension class same as follow all the Step till 9
  • First, use the io_data_provider input object reference to fetch the incoming data from the HTTP body
  • Code:
  • Method Code:

METHOD salesheaderset_update_entity.


DATA: ls_data TYPE zcl_zodata_project_mpc=>ts_salesheader,

ls_sales_head TYPE zms_sales_head.


"Read HTTP Body response using this method

TRY.

io_data_provider->read_entry_data( IMPORTING es_data = ls_data ).

CATCH /iwbep/cx_mgw_tech_exception INTO DATA(lv_exception). " mgw technical exception

ENDTRY.


"&... Read primay key from HTTP request

io_tech_request_context->get_converted_keys( IMPORTING es_key_values = is_key_val).


"Write your own business logic

IF ls_key_val-salesorder EQ ls_data-salesorder.

ls_sales_head-vbeln = ls_data-salesorder.

ls_sales_head-audat = ls_data-documentdate.

ls_sales_head-auart = ls_data-documenttype.

ls_sales_head-vkorg = ls_data-salesorganization.

ls_sales_head-vtweg = ls_data-distributionchannel.

ls_sales_head-spart = ls_data-division.

ls_sales_head-kunnr = ls_data-soldto.

ls_sales_head-kunwe = ls_data-shipto.

ls_sales_head-erdat = cl_abap_context_info=>get_system_date( ).

ls_sales_head-erzet = cl_abap_context_info=>get_system_time( ).

ls_sales_head-ernam = cl_abap_context_info=>get_user_technical_name( ).


INSERT zms_sales_head FROM ls_sales_head.

IF sy-subrc EQ 0.

COMMIT WORK.

er_entity = ls_data.

ELSE.

ROLLBACK WORK.

mo_context->get_message_container( )->add_message_text_only(

iv_msg_type = /iwbep/if_message_container=>gcs_message_type-error

iv_msg_text = TEXT-002 ).

RAISE EXCEPTION NEW /iwbep/cx_mgw_tech_exception( message_container = mo_context->get_message_container( ) ).

ENDIF.

ELSE.

mo_context->get_message_container( )->add_message_text_only(

iv_msg_type = /iwbep/if_message_container=>gcs_message_type-error

iv_msg_text = TEXT-002 ).

RAISE EXCEPTION NEW /iwbep/cx_mgw_tech_exception( message_container = mo_context->get_message_container( ) ).

ENDIF.


ENDMETHOD.

  • Select PUT Method fill the payload and execute the method
  • If the update was successful (see Figure 6.74), you only get an HTTP 204 (no content) response
  • Difference between PUT and PATCH Method, PATCH method Update single properties of an existing entry where PUT method update all properties of an existing entry
  • Payload
{
  "d" : {
    "SalesOrder" : "1200001050",
    "DocumentDate" : "2026-12-31T00:00:00",
    "DocumentType" : "",
    "SalesOrganization" : "US20",
    "DistributionChannel" : "10",
    "Division" : "10",
    "SoldTo" : "0007315101",
    "ShipTo" : "0001010904"
  }
}

RAP8: Early numbering

In this post will show you how to use early numbering . Step 1: Add early numbering key word in interface behavior definition and activate b...