Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
Showing results for 
Search instead for 
Did you mean: 

The, Why?

Are you bored with routine life of SAP Basis? Let’s do something interesting and add color to it. Let computer do the boring stuff for us but in some intelligent way. Let’s do some programming.

I will be writing a multi series blog post to describe how we can use little amount of programming to ease our daily work. In this first part, I will be setting the environment and try to build the understanding how do we address the automation problem for SAP.

First thing first. What are the things that we can automate! Well, any repetitive task can be automated. Some of them are easy to automate and some are critical. Like, say you want to check support pack level for a bunch of systems at once that can be easily automated. Whereas monitoring system performance can be tricky and tough to do. However, we can automate transport list management, User management, Client Management etc. that we encounter daily.

Second thing, what programming language to use the automation. I prefer Python or VBA over others as they are faster compared to .NET or JAVA.

Well, what we do after we chose the language? We need to think what problem we can solve. Let’s say we want to check status of client status in our whole landscape. This is a typical problem because sometime production client is left open after it was opened, and team forgot to close. This led to potential problem, and we have to check all clients and their status. This is really time consuming and boring. So, we can write a program that will login to each system and check the status of the client and return the result quickly. So, we have to read the data from SAP and store the information into some format that is readable to us.

To understand how we can target this problem, let me tell you that, SAP has lots of function to run their own work. Some of them are accessible from outside of SAP and those are called RFC enabled function. When you open any SAP function in SE37 you can see whether the function is RFC enabled or not. If it is then life is easy. Else if client permits then we can create wrapper function around your required function and make the wrapper function RFC enabled. Life become most critical when there is no such function delivered by SAP that suffice your requirement. Then you have to take help from ABAP team or if you yourself is good enough to write such an ABAP function for your requirement and make that function as RFC enabled.


There is one FM called RFC_READ_TABLE which I love very much as this can read the table directly. For doing some work you can directly read the table and fetch the information. And once you have that information you can use and manipulate to produce your desired result.

Things get noisy and critical when desired result cannot be obtained from one table or even multiple tables. You have you use customized program which is either SAP delivered or made by your own.

So, which FM’s are required. Well, there is no direct way to get the FM that will suffice your requirement. You have to google it or talk to ABAP team to get some idea which FM can be helpful. Also, look into SE80 which and apply your own intuition to look for the FM that might be interesting for your work.

For example, if you are looking to collect system hardware data you can use the function module SCUI_GET_HARDWARE_DATA that belong to Function Group SCUI in SE80. There will be several FM under the hood of this package, but we need to choose one that is RFC enabled. Sometimes you will get a perfect FM for your work but unfortunately that might not be RFC enabled. Then you have to wrap with your own function or write new ABAP code .

Next thing we need to understand is to how to request for the data from SAP and how to receive the data from SAP. To send query from outside of SAP to a FM in SAP we have something called “Import” option assigned to a function module.


However not all the parameters in Import option are used to send the data. If will depend on you which you want to use and how you want to use the parameter. Like, here in this QUERY_TABLE parameter we can pass the value of a table name say “T000” to query client information data.

The “Export” option is to import data from SAP. But the “Tables” option also provides great alternative to retrieve the data back from SAP in a Matrix format. Sometimes there won’t be any parameters under “Export” option and you should use parameters under “Tables” option to get the data. You need to build some understanding on these parameters on how to and when to use one to manipulate these data.


Once you understand that, now it’s time for the most important step. How any third-party program will talk to SAP. Well, there are API’s around SAP which you can use natively from your language of preference.  So, using the API’s built in functionality and calling them from your Native language you first create a connection object.

So to create a connection object, first you need to have a API installed in your computer. Then you call the API. When you call the object to create a connection to SAP, you have to pass the information that you always to do connect to SAP from logon pad. So, you pass system sid, hostname, instance number your username, password and optionally router information. You store them as string object and pass them to SAP connection object and let the API do the rest of the connectivity.

Before I end this part of blog post and comes up with more interesting part i.e. hands on activities with programming, I want to say that you can use some scripting feature as well as full fledge programming feature. I prefer programming flavor and I will continue to show that in next part. I will also try to show the difference between these two features in coming blog posts. I will also explore the VBA and Python to do the stuff as I use them most.

I will post a link for the next blog post here soon as it is published.

Stay tuned….
Labels in this area