Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
Showing results for 
Search instead for 
Did you mean: 
Product and Topic Expert
Product and Topic Expert
Companies are currently implementing web based applications as side-by-side extensions to their core SAP Business Suite or SAP S/4HANA system in order to enhance or substitute legacy SAP GUI base processes. In some cases it might be beneficial to embed a link to a SAP GUI transaction into a HTML page, either to gap a functionality that is not yet available within the web application or to provide the end users with an alternative, familiar way to perform a specific action.

The following steps explain two alternative methods to add a hyperlink to your web page, which, when clicked, starts the SAP GUI and runs a transaction with parameters.


Step 1: Find the correct ok-code

First determine the ok-code that runs the SAP GUI transaction. If a transaction is supposed to be called without parameter, the ok-code is equal to the transaction code. In that case you can skip this step.

The ok-code must comply with the following syntax:
*<transaction code> <field1>=<value1>;<field2>=<value2>;

where <fieldN> is a dynpro fieldname of a selection screen field that should be filled in advanced with <valueN>.

The asterisk skips the initial screen. If you cannot specify all mandatory fields or you do not want to skip the initial screen or the transaction does not have an initial screen, leave the asterisk out.

If you do not know the dynpro fieldnames of the selection screen fields that are supposed to be filled, proceed as follows:

As an example, all batch jobs should be displayed that start with letter Z and that are owned by user HUGO. The appropriate transaction for that task is SM37.

In order to find the dynpro fieldname that correspond to parameter Job Name, click on the input field and press F1. The Performance Assistant pops up. Click on icon Technical Information (screw wrench). You find the dynpro fieldname under section Field Description, e.g. BTCH2170-JOBNAME.

Repeat this procedure to also find the dynpro fieldname for User Name.

Eventually, you can compile the ok-code as follows:

This example will be used throughout this blog post.



Method 1: Download an SAP shortcut file

Create a download link to an SAP shortcut file. This methods works on all front end PCs where an SAP GUI is installed without further setup activity. However, a file may be downloaded every time a user clicks the link and the user must explicitly allow execution of the downloaded file.


Step 2.1: Create SAP shortcut file

In order to create an SAP shortcut file (extension *.sap), logon to the SAP GUI and run the transaction. Then select menu item

MoreSAP GUI settings and actionsCreate Shortcut...

Add parameters to the Transaction and specify the Location where the file should be stored. Afterwards, click Finish.


Step 3.1: Create download link to SAP shortcut file

Next you must create a download link to a SAP shortcut file. Considering the example above, assuming that the transaction should be run on SAP System PRD in client 100, the file content should look like shown below.
Description=PRD - Production
Title=Job Overview
WorkDir=C:\Users\Hugo\Documents\SAP\SAP GUI

Usually you would implement a HTML GET method on the server that sends the file as response with a HTTP header like:
Content-Disposition: attachment;

For a HTML only solution it is not sufficient to store the SAP shortcut file on the server and put a hyperlink on the HTML page that references that file, because the browser will render the file content as text without actually downloading it. To get around this, add the file content as data URL to your hyperlink tag.

If the SAP shortcut file is "PRD Job" and resides in the current directory, you can generate a data URL using the following Windows PowerShell command.
&{$b=Get-Content -Encoding Byte -Path ".\PRD Job"; "data:text/plain;base64," + [Convert]::ToBase64String($b)}

Add a hyperlink to your HTML page with the generated data URL as reference as shown in the code snippet below. The user can use the hyperlink to navigate to the SAP GUI job overview screen.
<title>Link to SAP GUI transaction (download SAP shortcut file)</title>

<a href='data:text/plain;base64,W1N5c3RlbV0NCk5hbWU9UFJE ... xVzZT0xDQo=' download=''>
Job Overview


When the user clicks the link, the behavior depends on the web browser and its settings.

Either the SAP shortcut file is downloaded and afterwards the user must trigger execution of that file.

Or a popup window appears giving the user the option to select an application that should be used to open the file. The user has to select executable sapshcut.exe, which (on Windows) most likely resides in folder C:\Program Files (x86)\SAP\FrontEnd\SAPgui\.

In both cases the user should mark option "Do this from now on."

A security message appears where the user must allow execution of the displayed ok-code.

If an SAP GUI session for the user and client is already active, the SAP GUI transaction is brought up immediately. Otherwise the user must provide a password first.


Method 2: Configure a Custom URL

This second method to add a hyperlink that starts a SAP GUI works on Windows front end PCs only and needs some setup work. It implements a custom URL that can be used to navigate to the SAP GUI transaction the same way one can navigate to any web resource.


Step 2.2: Start SAP GUI transaction via SAPshortcut

Program sapshcut.exe is part of the SAP GUI installation and can be used to run an SAP GUI transaction. You can skip this step. However, is is recommended to run SAPshortcut from Windows PowerShell once to verify that all SAP GUI components have been installed correctly.

Start Windows PowerShell and change directory to the SAP GUI installation directory on your local PC.
cd "C:\Program Files (x86)\SAP\FrontEnd\SAPgui"

Assuming you want to run the transaction of the example above on system PRD in client 100, execute the following command from Windows PowerShell:

Parameter -COMMAND holds the ok-code (without prefix /n) that you want to run.

If the ok-code contains a whitespace, it must be specified as a quoted string. To pass a quoted string as command parameter inside the Windows PowerShell, you must quote that quoted string, where the inner quotes must be prefixed by the escape character, which is also a quote. Thus, you end up with triple quotes.


Step 3.2: Register protocol handler in Windows registry

Next you must register protocol handler sapgui for custom URLs that comply to the following scheme:
sapgui:<sapshcut.exe arguments separated by &>

For example, with the transaction from the previous step:

To register a protocol handler and assign it to a shell command, open the Windows registry editor (regedit) and proceed as follows:

  • Add key HKEY_CLASSES_ROOT\sapgui

  • Add string "URL Protocol" to key HKEY_CLASSES_ROOT\sapgui

Next you need to add the command as a Windows Registry key as follows:
HKEY_CLASSES_ROOT\sapgui\shell\open\command = <path>\sapshcut.exe <arguments derived from "#1">

where #1 is the argument that contains the encoded custom URL including the protocol prefix, for example

You can use Windows PowerShell commands to convert the URL-encoded string to a list of arguments for executable sapshcut.exe.

First decode the URL. Use method WebUtility.UrlDecode of .NET assembly System.Net to do so.
Add-Type -AssemblyName System.Net

Afterwards remove prefix sapgui: from the URL by calling method replace. You may also want to remove double slashes in order to allow URLs starting with sapgui://

Convert the string into an argument list by splitting at character & and pass it to executable sapshcut.exe
sapshcut.exe $args.split('&')

The command sequence above must be run within a Windows PowerShell instance. Start powershell.exe with options -NonInteractive -NoProfile and -WindowStyle Hidden, see

Finally you should compile everything into a Windows registry file (extension *.reg) with the content below. All relevant keys are added to the Windows registry when the file gets executed.
Windows Registry Editor Version 5.00

@="Launch SAP GUI"
"URL Protocol"=""



@="powershell -NonInteractive -NoProfile -WindowStyle Hidden -Command \"& {Add-Type -AssemblyName System.Net; $args=[System.Net.WebUtility]::UrlDecode('%1').replace('sapgui:','').replace('//',''); &'C:\\Program Files (x86)\\SAP\\FrontEnd\\SAPgui\\sapshcut' $args.split('&')}\""


Step 4.2: Create a HTML page

Now you are ready to use custom URLs with protocol sapgui:

By using such a custom URL you can add a hyperlink to your HTML page that can be used to navigate to the filtered job overview screen in SAP GUI, as indicated by the following snippet.
<title>Link to SAPGUI transaction (follow custom URL)</title>

Job Overview




Two alternative methods to add a hyperlink to your web page for navigation to a parameterized SAP GUI transaction have been given. Method 1 works on all front end PCs without additional setup. Method 2 might be more convenient for the user, but requires setup work on the front end PC.

The latter method runs on Windows only. However, it should be possible to implement a similar approach on other operating systems that support custom URLs, in particular macOS.

If you need help with the SAP GUI or on another topic, Ask a Question on the SAP Community Q&A resource page.