46

Call fiori app from SAPGUI transaction

 2 years ago
source link: https://blogs.sap.com/2020/06/25/call-fiori-app-from-sapgui-transaction/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
June 25, 2020 2 minute read

Call fiori app from SAPGUI transaction

3 8 4,525

EDIT : There is a standard method to do this, it’s easy to use at least if you found it in the documentation 🙂

Thanks to Dennis Schulmeister-Zimolong

cl_lsapi_manager=>navigate_to_intent(
  object          = ls_ui5_navigation-semantic_object
  action          = ls_ui5_navigation-semantic_action
  parameters      = lt_lsapi_parameters
  navigation_mode = if_lsapi=>gc_s_navigation_mode-inplace
). 

Handling Cross-App Navigation for SAP GUI and Web Dynpro Apps


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 (In this case, 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 !


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK