Sample Code

OData Post Call – DPC_EXT CREATE ENTITY method

This sample code read the incoming data, populate the and raise exception is case of error. Here the ls_goodsissue is the structure where incoming data is stored. The variable has the same property as that of the entity in the SEGW transaction.


    DATA: ls_goodsissue       LIKE er_entity,
          lv_message          TYPE bapi_msg.


* Reading the incoming data
    io_data_provider->read_entry_data( IMPORTING es_data = ls_goodsissue ).


* Populate the entityset
 er_entity-purchaseorder = ls_poinfo-purchaseorder.

* Raising Exception in case of error
      mo_context->get_message_container( )->add_message_text_only(
                                    EXPORTING
                                      iv_msg_type = /iwbep/if_message_container=>gcs_message_type-error
                                      iv_msg_text = CONV bapi_msg( lv_message )
                                    ).
      RAISE EXCEPTION TYPE /iwbep/cx_mgw_busi_exception
        EXPORTING
          textid = /iwbep/cx_mgw_busi_exception=>business_error.

This code does not contain the logic which is required for processing (because that depends on the requirement). So it is not a complete sample code. ABAPers who already know the concepts can use this code for copy-paste and the new people can have some idea how the code can be written.

If you want to understand the concept of create method completely, do let me know in the comment.

Leave a Reply

Your email address will not be published. Required fields are marked *

error

Enjoy this blog? Please spread the word :)

Follow by Email
Twitter
LinkedIn
LinkedIn
Share