You can use the interface /IWFND/IF_MGW_BEC_API to implement a custom logic for executing the backend API. It is not always necessary to use BOPs in the SAP Gateway OData Channel.
You can implement the interface /IWFND/IF_MGW_BEC_API in the following cases:
For simple backend calls if the data types required for the backend calls are available in the SAP Gateway OData Channel.
Even in complex scenarios if the data types required for the backend calls are available in the SAP Gateway OData Channel.
The implemented interface (/IWFND/IF_MGW_BEC_API) can be registered in the method REGISTER_MAPPING_SPECIALIST of the EDP with mapping specialist attribute bop_type as /IWFND/IF_MGW_BEC_BOP=>GC_BOP_TYPE_CUSTOM.
Sample code for Execute Action:
DATA: ls_bookingdata TYPE bapisbdeta, lv_destination TYPE string, lv_airlineid TYPE bapisbdeta-carrid, lv_booking TYPE bapisbdeta-bookid, ls_booking TYPE bapisbdeta, ls_book_attr TYPE /iwfnd/om_mgw_sample_sflight_s=>booking_fields, lv_flightdate TYPE bapisbdeta-fldate, lv_cust TYPE bapisbdeta-customid, lv_connid TYPE bapisbdeta-connid, ls_return TYPE bapiret2, lt_return TYPE bapiret2_t, lv_exc_msg TYPE /iwfnd/bec_rfc_exception_text, ls_parameter LIKE LINE OF is_action_params-parameters. FIELD-SYMBOLS : <fs> TYPE any. mv_system_alias = iv_system_alias. * Get RFC Destination for System Alias lv_destination = get_destination( ). IF is_action_params IS SUPPLIED. CASE is_action_params-action_name. WHEN 'cancelbooking'. LOOP AT is_action_params-parameters INTO ls_parameter. CASE ls_parameter-name. WHEN 'airlineid'. lv_airlineid = ls_parameter-value. WHEN 'bookingnumber'. lv_booking = ls_parameter-value. WHEN 'connectid'. lv_connid = ls_parameter-value. WHEN 'flightdate'. lv_flightdate = ls_parameter-value. ENDCASE. ENDLOOP. * Cancel Booking CALL FUNCTION 'BAPI_SBOOK_CANCEL' DESTINATION lv_destination EXPORTING airlinecarrier = lv_airlineid connectionnumber = lv_connid dateofflight = lv_flightdate bookingnumber = lv_booking customernumber = lv_cust IMPORTING bookingdata = ls_booking return = ls_return EXCEPTIONS system_failure = 1000 MESSAGE lv_exc_msg communication_failure = 1001 OTHERS = 1002. IF sy-subrc EQ 1000. RAISE EXCEPTION TYPE /iwfnd/cx_mgw_tech_exception EXPORTING textid = /iwfnd/cx_mgw_tech_exception=>rfc_system_error rfc_failure_message = lv_exc_msg. ELSEIF sy-subrc EQ 1001. RAISE EXCEPTION TYPE /iwfnd/cx_mgw_tech_exception EXPORTING textid = /iwfnd/cx_mgw_tech_exception=>rfc_communication_error rfc_failure_message = lv_exc_msg. ELSEIF ls_return IS NOT INITIAL. * Error Handling APPEND ls_return TO lt_return. io_context->get_message_container( )->add_message( iv_msg_text = ls_return-message iv_msg_number = ls_return-number iv_msg_id = ls_return-id iv_msg_type = 'E' iv_system_alias = mv_system_alias iv_entity_type = iv_entity_name iv_message_creator = 'TEST_AGENT' ). ev_process_code = /iwfnd/if_mgw_bop_map=>cs_process_code-stop_processing. ENDIF. ENDCASE. ENDIF. |
Sample code for Registration:
CASE iv_entity_name. WHEN 'flight'. CASE iv_entity_operation. WHEN gc_operation_code_wr-execute_action. ls_mapping_specialist_attr-execution_mode = gc_operation_code_wr-execute_action. ls_mapping_specialist_attr-bop_type = /iwfnd/if_mgw_bec_bop=>gc_bop_type_custom. CREATE OBJECT ls_mapping_specialist_attr-be_api_ref TYPE ZCL_FLIGHT_BOOK_CANCEL. APPEND ls_mapping_specialist_attr TO et_mapping_specialist_attr. ENDCASE. |