Call fiori app from SAPGUI transaction

There are many blog posts that explain how to call sapgui transaction from Fiori launchpad.

Here is an example.

But what if you want to do the opposite : call Fiori App from sapgui transaction. Why ?

Let’s take this scenario :

Your customer has SAP ECC with many SAPGUI transactions that work great. He moved to S/4 HANA with a conversion project so that he could keep his old transaction.

Now he wants a new custom development that will be called from one of his old transaction. You have 2 options :

  • Create a new SAPGUI transaction and use “CALL TRANSACTION”  in ABAP
  • Create a new Fiori APP (of course !!)

The second choice should be the best option but we need a way to call the fiori app.

I created a little method to do this. It works from SAPGUI, from a web browser or from business client.

Note that either when you use the web browser or the business client, the fiori app will open in a new tab which is coherent with the functionnality of the fiori launchpad (when you call a sapgui transaction from a fiori app, it opens in a new tab).

Now let see the code !

 "! Call Fiori app from sapgui "! @parameter i_semantic_object | Semantic object "! @parameter i_action | action METHODS call_fiori_app_from_sapgui IMPORTING i_semantic_object TYPE /ui2/semantic_object i_action TYPE /ui2/action i_path TYPE string OPTIONAL. METHOD call_fiori_app_from_sapgui. DATA(business_client) = NEW cl_nwbc( ). DATA(business_client_context) = business_client->context_get( ). IF business_client_context IS INITIAL. "Create sicf node (for ITM, alias is created from sys id and client) DATA(node_path) = `/` && sy-sysid && `_` && sy-mandt. TRANSLATE node_path TO LOWER CASE. DATA(lo_start_url) = NEW /ui2/cl_start_url( iv_icf_node_path = node_path ). "add sap params "sy-mandt", "sap-language", "sap-language" lo_start_url->add_sap_params( ). "add fragment IF i_semantic_object IS NOT INITIAL. IF i_path IS NOT INITIAL. lo_start_url->change_fragment( iv_fragment = |{ i_semantic_object }-{ i_action }&{ i_path }| ). ELSE. lo_start_url->change_fragment( iv_fragment = |{ i_semantic_object }-{ i_action }| ). ENDIF. ENDIF. "start in browser if business client is not active lo_start_url->start_browser( ). ELSE. DATA business_client_url TYPE string. IF i_path IS NOT INITIAL. business_client_url = business_client_context-login_url && |#{ i_semantic_object }-{ i_action }&{ i_path }|. ELSE. business_client_url = business_client_context-login_url && |#{ i_semantic_object }-{ i_action }|. ENDIF. business_client->url_launch( url = business_client_url ). ENDIF. ENDMETHOD.

There is just one thing that you have to change in the code : you need a way to find your SICF node from the fiori launchpad url. (just after the comment “”Create sicf node (In this case, alias is created from sys id and client)”).

You can add a path at the end of the url to go directly to an entity by navigation.

Hope it will help !