- CREATE is used whenever you want to create a new entry into the respective collection.
- Using the read_entry_data method of the io_data_provider import object reference, you can retrieve the data that was passed along the POST request in the HTTP body. The entry is retrieved in the format of the entity type definition.
- 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. If you want to know the Step 9 details kinldy follow the step from the this link.
- Method Code:
METHOD salesheaderset_create_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.
"Write your own business logic
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.
ENDMETHOD.
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.
"Write your own business logic
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.
ENDMETHOD.
- If the CREATE operation was successful, you get an HTTP 201 response as shown below.
- First xecute the read or query method get the payload and Click on "Use as Request" button.
- Modify your pay load as per your need and select POST Method, add content-type as “application/json”
- Payload:
{
"d" : {
"SalesOrder" : "1200001050",
"DocumentDate" : "2026-12-31T00:00:00",
"DocumentType" : "ZSD",
"SalesOrganization" : "US20",
"DistributionChannel" : "10",
"Division" : "10",
"SoldTo" : "0007315101",
"ShipTo" : "0001010904"
}
}