I’ve already discussed how to Connect to SAP via Excel VBA and 10 code lines you can identify in SAP code. But I haven’t explained how to record a macro in SAP yet. In this article I’m going to explain You step by step how to record a macro in SAP using SAP Script Recording.
I am going to show You how to start your first recording, beginning of the new era of your SAP work.
First of all…
You need to open SAP application and log in. After that, having that main SAP window opened, click on the last icon with 2 small wheel gears. From the expanded list please select Script Recording and Playback, like on the image below.
When You select and click it, the pop up window will appear.
Please click More button to see more options.
In the first place You can see 2 active buttons – Play and Record – and one not active – Stop. You are interested in the Record button. After clicking it every move in SAP will be recorded. When You are finished click Stop button to stop recording.
Here You can also see the directory of your recorded scripts. You can change it if You want to. And You don’t have to bother about the format in the window below the path.
After You finish your recording go to the place from the directory. There You will see files with the .vbs extension. To see the content of the file just simply right click it, select Open with and choose Notepad.
After Notepad loads, the content for logging in will look like this.
If Not IsObject(application) Then Set SapGuiAuto = GetObject("SAPGUI") Set application = SapGuiAuto.GetScriptingEngine End If If Not IsObject(connection) Then Set connection = application.Children(0) End If If Not IsObject(session) Then Set session = connection.Children(0) End If If IsObject(WScript) Then WScript.ConnectObject session, "on" WScript.ConnectObject application, "on" End If session.findById("wnd").resizeWorkingPane 175,37,false session.findById("wnd/usr/txtRSYST-BNAME").text = "user" session.findById("wnd/usr/pwdRSYST-BCODE").text = "********" session.findById("wnd/usr/pwdRSYST-BCODE").setFocus session.findById("wnd/usr/pwdRSYST-BCODE").caretPosition = 10 session.findById("wnd").sendVKey 0
In this case I recorded my attempt to log in to SAP.
Everything after conditionals is your clicks and keyboard types in SAP. You can exchange the first part of your code for the connection code from my Connect to SAP article.
And that’s it!
Now You should know how record macro in SAP using SAP Script Recording. You know where to find it, You know how to use it. It will automate your daily SAP routines and make your daily tasks faster and easier.