Show TOC

Implementing /IWBEP/IF_MGW_EDP_MAP_CREATELocate this document in the navigation structure

Implementing /IWBEP/IF_MGW_EDP_MAP_CREATE for Create and Deep Insert — Inbound Mapping

The Inbound mapping method is provided with:

  • BOP DO

  • A set of BOP DOs processed by previous mapping specialists

  • The entity data (ER_ENTITY or ER_ENTITYSET or ER_DATA). The entity data can be partially filled by previous mapping specialists.

  • Operation specific parameters

To implement inbound mapping interface method /IWBEP/IF_MGW_BOP_MAP_CREATE~MAP_INBOUND for Create and Deep Insert operations, proceed as follows:

  1. The input parameter IO_DATA_PROVIDER (of type /IWBEP/IF_MGW_ENTRY_PROVIDER) contains the input request. IT_KEY_TAB contains the keys of an entity.

  2. Read the request data into a local variable.

  3. Create the BOP request using the input request.

  4. Set the BOP DO request.

Sample Code

DATA:
       lo_dataobject  TYPE REF TO /iwbep/cl_mgw_bop_sfl_bkcr_do, 
        ls_flightdata TYPE /iwbep/cl_mgw_edp_sfl_model_bs=>ts_flight,
        ls_book_data TYPE /iwbep/cl_mgw_edp_sfl_model_bs=>ts_booking,
        lt_booking TYPE STANDARD TABLE OF /iwbep/cl_mgw_edp_sfl_model_bs=>ts_booking,
        ls_request TYPE /iwbep/cl_mgw_bop_sfl_bkcr=>_params_request.

" All BOP classes have the types _params_request and _params_response.
" Use them to access the parameters for your backend call.

  TRY.
      io_data_provider->read_entry_data( IMPORTING es_data = ls_flightdata ).
    CATCH /iwbep/cx_mgw_tech_exception.
  ENDTRY.

  MOVE ls_flightdata-bookings TO lt_booking.
  READ TABLE lt_booking INDEX 1 INTO ls_book_data.

  IF NOT ls_book_data IS INITIAL.
    MOVE-CORRESPONDING ls_book_data TO  ls_request-booking_data.
*    ls_request-booking_data-customerid = '00000003'.
*    ls_request-booking_data-agencynum  = '00000002'.
    lo_bop_do->set_request( ls_request ).
  ELSE.
    ev_process_code = /iwbep/if_mgw_edp_map=>cs_process_code-stop_processing.
  ENDIF.
 
Implementing /IWBEP/IF_MGW_EDP_MAP_CREATE for Create and Deep Insert — Outbound Mapping

To implement outbound mapping interface method /IWBEP/IF_MGW_BOP_MAP_CREATE~MAP_OUTBOUND for Create and Deep Insert operations, proceed as follows:

  1. Get the BOP response.

  2. Check if there are any errors from the response. If yes, add the messages to the Message Counter.

  3. For Create operation, form the response data.

METHOD /IWBEP/IF_MGW_EDP_MAP_CREATE~MAP_OUTBOUND.
  DATA: ls_flight TYPE /iwbep/cl_mgw_edp_sfl_model_bs=>ts_flight.
  DATA: ls_key_tab TYPE LINE OF /iwbep/t_mgw_name_value_pair.

FIELD-SYMBOLS: <fs>TYPE ANY  
DATA: ls_response TYPE /iwbep/cl_mgw_bop_sfl_cre=>_params_response.
DATA: lo_bop_do TYPE REF TO /iwbep/cl_mgw_bop_sfl_cre_do.
DATA: ls_return TYPE LINE OF /iwbep/cl_mgw_bop_sfl_cre=>_params_response-return.
DATA lo_exp TYPE REF TO /iwbep/cx_mgw_busi_exception.
DATA: lr_msg_container  TYPE REF TO /iwbep/if_message_container.

  lo_bop_do ?= io_bop_do.
  lo_bop_do->get_response( IMPORTING es_response = ls_response ).

* Check for Error
  READ TABLE ls_response-return INTO ls_return WITH KEY type = 'E'.
  IF sy-subrc EQ 0.
    CREATE OBJECT lo_exp
      EXPORTING
        textid  = /iwbep/cx_mgw_busi_exception=>business_error
        message = ls_return-message.

    lr_msg_container = /iwbep/if_mgw_edp_map~mo_request_context->get_message_container( ).
    lr_msg_container->add_message_from_exception(
    EXPORTING
        io_exception = lo_exp
        iv_is_leading_message = abap_true    
        iv_entity_type = 'flight'
       ).
    ev_process_code = /iwbep/if_mgw_edp_map=>cs_process_code-stop_processing.

  ELSE.
    TRY.
        io_data_provider->read_entry_data( IMPORTING es_data = ls_flight ).
      CATCH /iwbep/cx_mgw_tech_exception.
    ENDTRY.

    CREATE DATA er_entity LIKE ls_flight.
    ASSIGN er_entity->*  TO<fs>
 <fs>= ls_flight.
ENDIF.

* Set the Keys
  ls_key_tab-name = 'airlineid'.
  ls_key_tab-value = ls_flight-airlineid.
  APPEND ls_key_tab TO et_key_tab.

  ls_key_tab-name = 'flightdate'.
  ls_key_tab-value = ls_flight-flightdate.
  APPEND ls_key_tab TO et_key_tab.

  ls_key_tab-name = 'connectid'.
  ls_key_tab-value = ls_flight-connectid.
  APPEND ls_key_tab TO et_key_tab.
 
ENDMETHOD. 

Continue with Error Handling in Mapping Specialists

Back to Developing Content on SAP Gateway OData Channel Using IWBEP