Skip to Content
Author's profile photo Former Member

How to call Odata service using /IWFND/CL_MGW_FAC_FACADE Class

In case if you have a requirement to call your Odata service using /IWFND/CL_MGW_FAC_FACADE class follow this blog.

The class /IWFND/CL_MGW_FAC_FACADE provides, via its various methods, the support to create, read, update and delete entities, to get entitysets and to execute actions.

/IWFND/CL_MGW_FAC_FACADE=>GET_ENTITY reads entity based on the following parameters

  1. IV_SERVICE_NAME: refer to the Technical Service Name; in order to find the technical name follow the below steps;
  • Go to tcode /n/IWFND/MAINT_SERVICE and then search for OData service using

2. IV_SERVICE_NAME: refer to service version

  • Go to tcode /n/IWFND/MAINT_SERVICE and then search for OData service using the ablove screen will display the Odata service from that we need to pick the version.

3.  IV_SERVICE_NAME: refer to the entity set, defined in the service. We can find using tcode SEGW=>Choose the gateway service=>go to Entity Sets folder and select the entity set

4. IT_KEY_TAB: This is mainly for inputs required for the entity set.
5. IO_REST_REQUEST: Rest request
6. ER_ENTITY: Will have the result

This blog contain only the usage of create entity, if you get a understanding how to create you can use update, delete and read entity APIs.
In my case I pass information to create an incident in a different system and returns the entity with the Unique Identifier and the information of the incident.
Coding Needed:

** Create rest_request  object
DATA:  request TYPE REF TO /IWCOR/if_rest_request.
CREATE OBJECT request TYPE /iwcor/cl_rest_request.
*** Fill input parameters
 data: ls_key_tab                TYPE /iwfnd/s_mgw_name_value_pair,
            lt_key_tab                TYPE TABLE OF /iwfnd/s_mgw_name_value_pair,
            lx_busi_exception         TYPE REF TO /iwfnd/cx_mgw_busi_exception,
            lx_tech_exception         TYPE REF TO /iwfnd/cx_mgw_tech_exception,
            lv_errorflag              TYPE c LENGTH 1.

            ls_entity TYPE <data structure>.

ls_entity-<field> = <some value>.
assign LS_ENTITY to <FS_INT>.
CALL METHOD /iwfnd/cl_mgw_fac_facade=>CREATE_ENTITY
           iv_service_name    = '*_SRV'
           iv_version         = '0001'
           iv_entity_set_name = '*Set'
           IS_ENTITY        = LS_ENTITY
           io_rest_request    = request
           cr_entity          = lr_entity.

     CATCH /iwfnd/cx_mgw_busi_exception INTO lx_busi_exception.
       lv_errorflag = abap_true.
     CATCH /iwfnd/cx_mgw_tech_exception INTO lx_tech_exception.
       lv_errorflag = abap_true.

Disadvantage of this approach:
facade is meant to be called from an incoming REST call via the ICF. That’s for instance why you find the io_rest_request object in each of the facade’s methods.

Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Thanks Dhinu! Very detail and insightful.