Skip to Content
Technical Articles
Author's profile photo Shunichiro Yamamoto

How to launch SAPGUI with SSO from Fiori Launchpad

Introduction

Starting with just 25 applications in 2013, SAP Fiori (Fiori 1.0) has grown to have over 10,000 applications in just 5 years. In particular, the number of applications has increased dramatically since Fiori 2.0, which was adopted for the 2015 S / 4HANA 1511 (Enterprise Management). The application type SAPGUI (in other words, WebGUI transaction with Berize theme) is supporting rapid growth in Fiori application.

In Fiori UX, SAP Fiori Launchpad is an entry point for all business operations, and SAP Fiori Elements created by noncoding with CDS annotation leads to the next transactions by giving notice.

Since Fiori is Web-based, its UX will be further improved by further advancement of Web technology and improvement of network speed and quality through the spread of 5G network. However, in the transition period, there is definitely a customer need to use SAPGUI (for Windows).

For these requirements, I would like to introduce sample ABAP code using Business Server Pages (BSP), one of the classic Web technology in SAP.

Things I want to do

Click the SAPGUI Launcher tile on SAP Fiori Launchpad …

 

SAPGUI starts without userid and password. You can configure a tile for Web GUI (SAPGUI for HTML) with standard procedures, but not SAPGUI.

 

Coding

Let’s see concretely how to code it. In this example, I use the old-school Web technology called BSP (Business Server Pages). For those of you who do not know, BSP is ABAP version of JSP (Java Server Pages) and ASP (Active Server Pages), and is a scriptlet coded in ABAP. Please refer to the sample code that appears later.

Architecture and Interaction Sequence

The BSP application ZCCSAPGUI is the hero of this blog. The ZCCSAPGUI application consists of two pages, default.htm and createSapGuiShortcut.htm. Let’s see concretely what each page is doing.

 

* Adoption of BSP is not essential. You can choose other web technologies.

* In this case, I judge the web browser by using client side JavaScript, but it is also possible to judge it on the server side (e.g. GET_USER_AGENT method of IF_HTTP_REQUEST interface).

Code Sample: default.htm

The body of HTML is very simple. It is like the template of SAPUI5. Everything is controlled by JavaScript runtime.

<%@page language="abap" %>
<!DOCTYPE HTML>
<html>
<head>
<title>SAPGUI Launcher</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta charset="utf-8">
<script src="/sap/bc/ui5_ui5/ui2/ushell/resources/sap-ui-core.js"
        id="sap-ui-bootstrap"
        data-sap-ui-theme="sap_belize"
        data-sap-ui-libs="sap.m">
</script>

<!-- 中略 -->

</head>
<body class="sapUiBody" id="content">
</body>
</html>

 

Next, let’s see what the main process JavaScript is doing. First of all, sap.ui.getCore().AttachInit() is called to define the SAPUI 5 component to construct the HTML body. Call launchSapgui() at the end of the process.

The main feature of launchSapgui() is the isSupported() for Web browser detection. In the sample code below, only Microsoft Internet Explorer 11 and Edge are allowed. For IE 11 or Edge, display the message “Please open SAPGUI shortcut within 5 seconds” and open createSapGuiShortcut.htm on the next page. Tab closes automatically after 5 seconds.

For other Web browsers, display the message “Please contact the system administrator” and close the tab.

var userAgent = window.navigator.userAgent.toLowerCase();
var appVersion = window.navigator.appVersion.toLowerCase();

var getBrowser = function() {
    var browser = 'unknown';

    if (userAgent.indexOf("msie") != -1) {
        if (appVersion.indexOf("msie 6.") != -1) {
            browser = 'ie6';
        } else if (appVersion.indexOf("msie 7.") != -1) {
            browser = 'ie7';
        } else if (appVersion.indexOf("msie 8.") != -1) {
            browser = 'ie8';
        } else if (appVersion.indexOf("msie 9.") != -1) {
            browser = 'ie9';
        } else if (appVersion.indexOf("msie 10.") != -1) {
            browser = 'ie10';
        } else {
            browser = 'ie';
        }
    }

    if (userAgent.indexOf('trident/7') != -1) {
        browser = 'ie11';
    } else if (userAgent.indexOf('trident/8') != -1) {
        browser = 'ie11';
    } else if (userAgent.indexOf('edge') != -1) {
        browser = 'edge';
    } else if (userAgent.indexOf('chrome') != -1) {
        browser = 'chrome';
    } else if (userAgent.indexOf('safari') != -1) {
        browser = 'safari';
    } else if (userAgent.indexOf('opera') != -1) {
        browser = 'opera';
    } else if (userAgent.indexOf('firefox') != -1) {
        browser = 'firefox';
    }

    console.log("User Agent: " + userAgent);
    console.log("Appicaiton Version: " + appVersion);
    console.log("Browser Name: " + browser);

    return browser;
};

var isSupported = function(browsers) {
    var browser = getBrowser();
    for (var i = 0; i < browsers.length; i++) {
        if(browsers[i] == browser) {
            return true;
        }
    }
    return false;
};

var launchSapgui = function() {
    jQuery.sap.require("sap.m.MessageBox");
    if (isSupported(['ie11', 'edge'])) {
        sap.m.MessageBox.information("Please open the SAPGUI shortcut within 5 seconds.", {
            title: "SAPGUI Launcher",
            onClose:  function(oAction) { window.close(); },
            styleClass: "",                                      // default
            initialFocus: null,                                  // default
            textDirection: sap.ui.core.TextDirection.Inherit     // default
        });
        window.setTimeout('window.close();', 5000);
        location.href = "createSapGuiShortcut.htm?sap-client=100&sap-language=EN&transaction=<%= transaction %>";
    } else {
        sap.m.MessageBox.error("Your browser is not supported. Please contact your system administrator.", {
            title: "SAPGUI Launcher",
            onClose: function(oAction) { window.close(); },
            styleClass: "",                                      // default
            initialFocus: null,                                  // default
            textDirection: sap.ui.core.TextDirection.Inherit     // default
        });
    }
}

sap.ui.getCore().attachInit(function () {
    var app = new sap.m.App("app", {
        initialPage: "page"
    });
    var page = new sap.m.Page("page", {
        title : "SAPGUI Launcher",
        showNavButton : false
    });
    app.addPage(page);
    app.placeAt("content");
    launchSapgui();
});

* The above is just sample code. Please apply latest browser detection logic.

Code Sample: createSapGuiShortcut.htm

If the web browser is IE11 or Edge, createSapGuiShortcut.htm will be called from default.html. The event handler is the hero in this page. The following ABAP code is a sample of the OnRequest event handler. The process flow is briefly summarized as follows.

  1. Generate MYSAPSSO2 (authentication token)
  2. Generate contents of SAPGUI shortcut file starting from “[SYSTEM]”
  3. Send the generated SAPGUI shortcut to the HTTP response

In the third, it is important to set “Content-Type: application/x-sapshortcut” in the HTTP response header. This header makes HTTP response behave as a SAPGUI shortcut.

In addition, you can switch SAP transaction immediately after startup as you like (default is SMEN), by the transaction code parameter passed from the previous page.

data:
  mysapsso2      type string,
  shortcut_file  type string,
  host           type string,
  instancenumber type instanz-systemnr.

call function 'CREATE_RFC_REENTRANCE_TICKET'
  importing
    ticket                 = mysapsso2
  exceptions
    ticket_logon_disabled  = 1
    ticket_creation_failed = 2
    kernel_too_old         = 3
    others                 = 4.

if transaction = ''.
  transaction = 'SMEN'.
endif.

call function 'GET_SYSTEM_NUMBER'
  importing
    instancenumber = instancenumber.

runtime->server->get_location(
  importing
    host = host
).

concatenate              '[System]'                      cl_abap_char_utilities=>cr_lf into shortcut_file.
concatenate shortcut_file 'Name='          sy-sysid      cl_abap_char_utilities=>cr_lf into shortcut_file.
concatenate shortcut_file 'Client='        sy-mandt      cl_abap_char_utilities=>cr_lf into shortcut_file.
concatenate shortcut_file 'GuiParm='       host                                        into shortcut_file.
concatenate shortcut_file instancenumber                                               into shortcut_file separated by ' '.
concatenate shortcut_file                                cl_abap_char_utilities=>cr_lf into shortcut_file.
concatenate shortcut_file '[User]'                       cl_abap_char_utilities=>cr_lf into shortcut_file.
concatenate shortcut_file 'Name='          sy-uname      cl_abap_char_utilities=>cr_lf into shortcut_file.
concatenate shortcut_file 'at="MYSAPSSO2=' mysapsso2 '"' cl_abap_char_utilities=>cr_lf into shortcut_file.
concatenate shortcut_file '[Function]'                   cl_abap_char_utilities=>cr_lf into shortcut_file.
concatenate shortcut_file 'Command='       transaction   cl_abap_char_utilities=>cr_lf into shortcut_file.
concatenate shortcut_file '[Options]'                    cl_abap_char_utilities=>cr_lf into shortcut_file.
concatenate shortcut_file 'Reuse=0'                      cl_abap_char_utilities=>cr_lf into shortcut_file.

runtime->server->response->set_header_field( name = 'content-type' value = 'application/x-sapshortcut').
runtime->server->response->set_cdata( data = shortcut_file ).

 

Testing

Well, let’s actually try it. The screen image of the second chapter was Edge, so in this chapter I will use the screen image of IE11. Let’s click the SAPGUI Launcher tile.

 

A separate tab opens and SAPGUI shortcut has been downloaded, so select “Open file” within 5 seconds and execute the shortcut. After 5 seconds from the screen display, the tab is closed.

 

If Internet Explorer security warning appears when opening a shortcut, click “Allow”. Check “Do not show me the warning for this program again” as necessary.

 

Next, SAPGUI security warning will be displayed, but click “Allow” here as well. Please check “Remember my decision”, if necessary.

 

An SAPGUI (for Windows) has been launched as expected.

 

Incidentally, if you run it on an unsupported browser, the following error message will be displayed. In this case, IE11 or Edge is supported, and it is an example executed by Chrome as representative unsupported one.

 

Closing

Thank you for your reading. How was it?

This sample code is a slightly tricky implementation returning an SAPGUI shortcut as an HTTP response, and supported web browsers are limited. However, I think this is relatively easy to adopt for a controlled enterprise.

Personally, I am hoping that the automation and sophistication with SAP Leonardo technology will eliminate the critical tasks that require SAPGUI for Windows. On the other hand, those tasks are not immediately automated. I hope that this sample code is useful as one of the transition measures.

By the way, I’m a non-ABAPer. (my comfort programming language is C.)

Assigned Tags

      15 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Michelle Crapo
      Michelle Crapo

      I liked it.  It looks a bit hard to implement.    The one that I've used is Step-by-step to enable transactions.  The link will download the PDF.  But this is interesting.  I'll have to try it to see the differences.

       

      Author's profile photo Shunichiro Yamamoto
      Shunichiro Yamamoto
      Blog Post Author

      Thank you for reading. I checked the document you shared. The biggest difference is whether to launch SAPGUI for HTML or SAPGUI for Windows. In my post, SAPGUI for Windows is launched, NOT SAPGUI for HTML in any web browser.

      Author's profile photo Sasi Kumar A
      Sasi Kumar A

      Can you share document for this.Were is need to deploy bsp application into server

      Author's profile photo Jörg Knaus
      Jörg Knaus

      Thanks for sharing

      Something you might want to try: When using netweaver business client (windows) the gui transaction in fiori launchpad are called with the windows gui instead of webgui

       

      Author's profile photo Shunichiro Yamamoto
      Shunichiro Yamamoto
      Blog Post Author

      Thank you for your information! I will check it asap.

      Author's profile photo Daniel Augusto Rodriguez Navarro
      Daniel Augusto Rodriguez Navarro

      Hello Jörg can you explain a little bit more on how to try this?? I already can call from a fiori lunchpad transactions of the ERP but they open in sap net weaver (web)

      Author's profile photo Jörg Knaus
      Jörg Knaus

      yes, from browser/fiori launchpad it will be as web

      with your sapgui installation you also get a windows version of netweaver business client (local installation on client), if you start fiori launchpad from here, the transactions will open with local gui.

       

      Author's profile photo Sandra Thimme
      Sandra Thimme

      If you "must" use the FLP only, see the following blog by Jorge Baltazar (RIG Australia):

      https://blogs.sap.com/2020/01/06/sap-fiori-for-s-4hana-launch-sap-business-client-from-sap-fiori-launchpad/

      If not you could use SAP Business Client with the SAP Fiori launchpad connection to use the FLP as a single entry point including native SAP GUI for Windows transactions:

      https://help.sap.com/viewer/f526c7c14c074e7b9d18c4fd0c88c593/7.0.6/en-US/e12b8b6b73624b019c6f41cea98f6d07.html?q=fiori%20integration

       

      Author's profile photo freddie botha
      freddie botha

      Good morning,

      This seems to be a very good solution, if we can actually get it to work.

      I have some questions that I want to ask, is that ok?

      Thanks,

      Freddie Botha

      Author's profile photo Thomas Kalbermatten
      Thomas Kalbermatten

      Hi, we use that solution for a long time, right now, we are changing to Edge Chromium, did you get it work there? It opens the MYSAPSSO2 file, but doesn't open SAP Gui. Is there a File Link missing from Windows site, or a browser issue.

      Author's profile photo Aqib Jamil Pathan
      Aqib Jamil Pathan

      Hi!

      We are trying to implement using webdynpro. Has anyone made it work using this technology?

      File download does not trigger but works fine in BSP application.

       

      Regards,

      AQIB

      Author's profile photo Judhajit Dhar
      Judhajit Dhar

      Hello Shunichiro Yamamoto ,

      I have an same issue when am trying to launch via Edge browser, a file is created with the name createsapguishortcut.htm and it opens as a htm file in the browser , it doesn't invoke SAP GUI.

      But the same code works fine with IE11 and it invokes the popup which open via SAP GUI.

      Could you please help me if am missing something here or we need to pass any other method in runtime->server->response-> so as to have the file created as createsapguishortcut.sap.

       

      I have checked other blogs and found this blog the most useful, hence asking my query here.

      Thanks,

      Judhajit.

      Author's profile photo UAB SAP Cloud
      UAB SAP Cloud

      Hi

      It's very interesting, congratullations.

      I have configurated, but I have two doubts. Is the code complete?.. because the bsp applications is not working fine... and the other thing, it's missig the path : sapbc//ui5/ for the bsp application. So, I can add to the Fiori

       

      Thanks

       

      Author's profile photo SUMIT KHULLAR
      SUMIT KHULLAR

      Hi,

      Does any one has a step by step guide to implement the above.

      Thanks in advance.

      Regards

      Author's profile photo Sergio Enrique Garbati Kreiner
      Sergio Enrique Garbati Kreiner

      Thank you very much Shunichiro Yamamoto

      Your solution is working here with Chrome and Firefox also!

      I've done just a small modification to the OnRequest event handler to get the server's IP address instead of the hostname as in some cases the hostname without the domain does not resolves the IP address:

      change 

      data:

       mysapsso2 type string,
       shortcut_file type string,
       host type string,
       instancenumber type instanz-systemnr.

      to 

      data:

       mysapsso2 type string,
       shortcut_file type string,
       host type string,
       instancenumber type instanz-systemnr,
       serverlist type TABLE OF MSXXLIST_V6. 
       DATA: wa_serverlist LIKE LINE OF serverlist.

      and

      runtime->server->get_location(
      importing
      host = host
      ).

      to 

      call function  'TH_SERVER_LIST'
        TABLES
          LIST serverlist.

      read table serverlist into wa_serverlist INDEX 1.
      host wa_serverlist-hostaddr_v4_str.

       

      Regards,

      Sergio