Skip to Content

Introduction to SAP Gui Scripting
As Bill Gates once said: “I will always choose a lazy person to do a difficult job… because, he will find an easy way to do it”

Scripting can be used to make repetitive time consuming tasks quick and easy. It takes some time and dedication to write a script but in the end your investment can really pay off. Your script can be faster and more accurate than you! So you have to ask yourself: Should I spend a few hours getting a script to work? If you’re only going to do something once then it’s probably not worth the time. However remember two things; when you do write a script for something, you have that script forever and you’re sharpening your scripting skills with every script you write. So go ahead – Think like a lazy person and you might end up more productive!

Starting Out

First you will need a primer on VBScripting – SAP GUI Scripting is written in Microsoft’s VBScript language. This Scripting language is easy to learn is able to handle most simple tasks. It has been included in Windows since Windows 98 so it’s fairly well documented. Microsoft’s VBScript User’s Guide can be found here: []

For more complicated tasks I’ve wrote front ends in Visual Basic and then built and run a VBScript on the fly. Remember the sky is the limit with scripting so if you can imagine it, it can be done.

Of course you’ll also need to know about SAP Gui Scripting. In order for your VBscripts to access the SAP GUI and manipulate data you’ll need to use an API provided by SAP. You can find documentation for the SAP Gui API here:  SAP Gui Scripting API []

Once you’ve gathered the proper documentation you can start to develop scripts!

Keep a few things in mind when you write your scripts-

Make it reusable – Think about other possibilities for your scripts. Spending an extra 5 min writing in an extra feature can end up saving you an hour or two down the road when you might need it. Example – I once wrote a script to lock users. Two extra minutes of coding and it also could unlock them. These two minutes saved me an hour of work a few months later.

Do a good job with the comments – I routinely come back to scripts that I wrote one or two years ago. I can’t remember the specifics of what I was working on at the time so good comments help you understand what you were doing at the time. Some programmers say that good comments are more important than the actual code!

Scripting is dangerous! – Everyone makes mistakes. Automation gives you the ability to make mistakes. Many mistakes… very quickly. So be careful! Make sure to test your script on a sandbox before you decide to run it in Production. I cringe whenever someone asks me to run a script in production because it can be very dangerous. So for your own sake, Be Careful! Or at least make sure your Resume is up to date.

And finally – Start small – Do something simple before you take on something crazy, like scripting system refreshes. You must crawl before you can walk young grasshopper!

Setting up your Environment for SAP Gui Scripting

There are two things you’ll need to setup in order to run Gui Scripts. First you’ll need to configure your client, then the system that you are connecting to.

Step 1: Setup your Client

First, you’ll need to setup the SAP Gui Client to allow scripting on your local machine.  I’ll be working with SAPGUI 7.30 on Windows.

In the options panel of your GUI, you’ll need to select “Accessibility & Scripting” and then “Scripting” in the left hand column. Then you are presented with three checkboxes.


To start, I would suggest selecting all three check boxes. Here is a description of what they do: 

Enable Scripting – This box simply allows scripting on your GUI. (Has nothing to do with the server)

Notify when a script attaches to SAP GUI – Pops up a yes/no box when a script attempts to use the GUI. This is useful to have on because it give you a point to make sure you want to run what you are running. If you don’t have this on, the script will run without any confirmation.

Notify when a script opens a connection – This setting pops up a confirmation when your script connects to a system. I generally turn this off when I run a script that connects to the system multiple times to do what it does. Otherwise I leave this setting on.

Once you’ve checked “enable scripting” you’re ready to run scripts on the client side. Next, you’ll need to check your settings on the server side.

Step 2: Setup your SAP System

You can enable scripting by setting the profile parameter sapgui/user_scripting to TRUE. The value set using this procedure will be lost when the system is restarted. If the administrator edits the application server profile of the SAP System to include sapgui/user_scripting = TRUE, scripting will be enabled by default when the server is restarted.




  1. Start transaction RZ11
  2. On the Maintain Profile Parameters screen, enter “sapgui/user_scripting.
  3. Choose Display.
  4. In the Display Profile Parameter Attributes screen, choose Change value.
  5. Enter “TRUE” in the new value field.
  6. Click the Save Button.

Once you’ve done these two things – You’re ready to run scripts.

I’ll continue to add to this series on SAP GUI Scripting. Stay tuned!

You must be Logged on to comment or reply to a post.