Sap-R3-Automation-tool
SAP R3 is still used by numerous companies and many people still use it everyday at work, sometimes running the same reports all over again everyday. This is where this small solution comes to play.
This repositerie provides a framework to be applied to any situation described above. It cannot be simply forked or copied to make it work on your situation as you will be requiered to do some modifications and record your own process in SAP.
Technologies
This project leverages microsoft excel, VBA scripting language and python 3.6 with the following packages:
This automation proposition is only working for Windows OS, however they are many ways to get similar or even better results on other OS
Installation Guide
Before running the application, first install the following dependencies:
pip install pywin32
pip install pandas
How does that work ?
SAP R3 allows you to record your own reports in VBA by default so you can simply launch the VBA script later to let your machine fetch the data on its own. (Recording process below). So the idea is to have programs to log us in SAP R3 in the right SAP environment, launch and save the needed reports , clean the data and begin analysis.
Still a bit confused ?
A picture is worth a thousand words:
Basically, the first script Sap_login.py will allow you to connect automatically to your SAP user interface. Then vba_macros_launcher.py will be able to launch every macro recorded from SAP and stored into the excel file VBA_Macro_4_sapR3.xlsm
Now it is important to mention again that those VBA macros will need to be recorded by the user on their own use-case.
In my case, once those data in .txt are created each day I need to transform this data, clean it and filter the relevant records, you will find these steps under sap_reports_analysis.py
Okay, but how to I get these created automatically everyday without human actions ?
Windows comes a scheduler that can execute python script on a schedule, you simply need to provide the right virtual environment and the right script. More info on how to set up the scheduler here
How can I record my own SAP Tcode ?
The process to record your own process from sap into a vba code is quite straightforward:
- Open SAP Logon, and then select the SAP system to which you want to sign in.
- Select Customize Local Layout (Alt F12), and then select Script Recording and Playback.
- Select More.
Under Save To, provide the path and file name where you want to store the captured user interactions.
Looks cool, but why not simply use an API to access data from SAP directly in python?
Yeah this one hurts. Many people in their company simply do not have access to such tools. And in the case of SAP R3, I am not aware of anything created for python. Now mind you, SAP S4 does have such possibility and if I could have gone for that, that would have been the prefered solution as its faster, more stable and simply a more elegant way.
Contributors
Dorian Gloinec