Login to SAP Using Python
The Programming Language Python gives you many possibilities to use SAP in different ways.
One of them is Logging into SAP without providing Client Number, User Name, or Password.
You might be surprised how this is possible !!
But, to use this kind of feature you need to maintain Client Number, User Name, passwords, etc in your Python Program.
Let me give you more information on this.
There are few Pre-Requisites before we begin.
- SAP GUI must be installed in your machine. As you are on SCN site I expect you must already know this 😉 ( If not Click here )
- Python also must be installed in your machine. How to Install( Click Here)
Once you have these Softwares installed in your machine you can write your program or copy the below code and use it.
Obviously, with few modifications as below 😉
<SID> = You need to mention System SID.
<NUM>= Client Number.
<UserName>= User name through which you wanted to log in to SAP.
<Password>= Maintain your User password.(And Update the password whenever there is a change)
Don’t worry I have copied here the same code as shown in the above screenshot.
import os import tkinter as tk WIDTH = 200 HEIGHT = 300 root = tk.Tk() canvas = tk.Canvas(root, height=HEIGHT, width=WIDTH) canvas.pack() def myClick1(): <SID> = os.system('start sapshcut.exe -system=<SID> -client=<NUM> -user=<UserName> -pw=<Password>') <SID>.pack() def myClick2(): <SID1> = os.system('start sapshcut.exe -system=<SID> -client=<NUM> -user=<UserName> -pw=<Password>') <SID1>.pack() button1 = tk.Button(root, text="<SID>", command=myClick1) button1.pack() button2 = tk.Button(root, text="<SID>", command=myClick2) button2.pack() root.mainloop()
Note: Before running the above program you need to make sure the Tkinter is installed on your windows and also adjust the height and width as per your requirement.
I have used Visual Studio to write and execute this code.
The above program directly won’t work it will require a few packages that need to be installed using pip. Before executing the above program you need to install pip install Tkinter ( For more information you can click here )
So here you go, When you run the above program you will get something like below as a GUI PopUp.
When you click on any of the buttons <SID> or whatever you have mentioned that system will connect and opens up with the maintained credentials. So Enjoy 😀
Here you go !!
This is not the end 🙂
You can even use this feature or program for opening any of the URLs in the default browser of your computer, for example, google.com or maybe Monitoring any of the JAVA Portals.
So, to use this you need to include the below:
and Run the Program :
Google.com will be opened in your default browser :
If you like this or helps you then please hit Like & Comment And Obviously share 🙂