Skip to Content
Technical Articles
Author's profile photo Stephan Molden

Multiple backend systems in Gateway Server – enhanced

Recently, I had to roll out a productive SAP Fiori App in a corporate Gateway Server to a new backend system. Besides all the necessary customizing the Odata service connection had to be enhanced. The first picture shows the initial setup.

In his blog post Andre Fischer shows in detail how we can maintain multiple backend systems for one Odata service by maintaining user roles or host names.

Assuming that this customizing works like other SAP Standard tables I initially thought it would be sufficient to add the new System Alias with a role assigned instead of investigating the corresponding role for the existing one.

This is what my attempt looked like:

Unfortunately this didn’t work. During my analysis I found the enhancement spot /IWFND/ES_MGW_DEST_FINDER including the Business AddIn /IWFND/BD_MGW_DEST_FINDER which we can apply to solve this problem. To activate this Business AddIn, we first need to implement the enhancement spot via SE18. The Business AddIn has a filter we must restrict to our service.

We can now place our own logic in the implementing class method /IWFND/IF_MGW_DEST_FINDER_BADI~GET_SYSTEM_ALIASES to determine the right backend system and flag it as default.

        TRY .
            DATA(lo_destin_finder) = /iwfnd/cl_destin_finder=>get_destination_finder( ).
            DATA(lt_user_roles) = lo_destin_finder->get_roles_for_user( iv_user = iv_user ).
            LOOP AT ct_system_aliases ASSIGNING FIELD-SYMBOL(<fs_alias>)
              WHERE user_role IS NOT INITIAL.
              IF line_exists( lt_user_roles[ user_role = <fs_alias>-user_role ] ).
                <fs_alias>-is_def_for_meta = abap_true.
                <fs_alias>-is_default = abap_true.
                DATA(l_role) = <fs_alias>-user_role.
            IF l_role IS NOT INITIAL.
              DELETE ct_system_aliases WHERE user_role <> l_role.
          CATCH cx_root.
            RAISE EXCEPTION TYPE /iwfnd/cx_mgw_dest_finder.

The above code checks if the current user has a maintained role. In case of a maintained role, the system will apply the new connection. In any other case the connection without a role.

Let me know if this example on how to use the Badi /IWFND/BD_MGW_DEST_FINDER is helpful.

Happy coding!

You can find this example also on github.

Assigned Tags

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

      Thank you very much for this example. I also have published an implementation of the destination finder that uses http custom headers.

      Best Regards,