Site icon SAP Human Resources Experts And Solutions

SAP Scripting

Small instruction about SAP scripting.

Activate SAP Scripting in GUI settings (SAP Logon settings).

Open SAP and hit “Record macro” in GUI menu. Run all needed steps and stop recording.

As a result you’ll get file with script. For example I’ve a script of creating 0015 infotype record:

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[0]”).maximize
session.findById(“wnd[0]/tbar[0]/okcd”).text = “pa30”
session.findById(“wnd[0]”).sendVKey 0
session.findById(“wnd[0]/usr/subSUBSCR_PERNR:SAPMP50A:0110/ctxtRP50G-PERNR”).text = “609”
session.findById(“wnd[0]”).sendVKey 0
session.findById(“wnd[0]/usr/tabsMENU_TABSTRIP/tabpTAB01/ssubSUBSCR_MENU:SAPMP50A:0400/subSUBSCR_ITKEYS:SAPMP50A:0350/ctxtRP50G-CHOIC”).text = “15”
session.findById(“wnd[0]/usr/tabsMENU_TABSTRIP/tabpTAB01/ssubSUBSCR_MENU:SAPMP50A:0400/subSUBSCR_ITKEYS:SAPMP50A:0350/ctxtRP50G-SUBTY”).text = “0030”
session.findById(“wnd[0]/usr/tabsMENU_TABSTRIP/tabpTAB01/ssubSUBSCR_MENU:SAPMP50A:0400/subSUBSCR_TIME:SAPMP50A:0330/ctxtRP50G-BEGDA”).text = “100914”
session.findById(“wnd[0]/usr/tabsMENU_TABSTRIP/tabpTAB01/ssubSUBSCR_MENU:SAPMP50A:0400/subSUBSCR_ITKEYS:SAPMP50A:0350/ctxtRP50G-SUBTY”).setFocus
session.findById(“wnd[0]/usr/tabsMENU_TABSTRIP/tabpTAB01/ssubSUBSCR_MENU:SAPMP50A:0400/subSUBSCR_ITKEYS:SAPMP50A:0350/ctxtRP50G-SUBTY”).caretPosition = 4
session.findById(“wnd[0]/tbar[1]/btn[5]”).press
session.findById(“wnd[0]/usr/txtQ0015-BETRG”).text = “11”
session.findById(“wnd[0]/usr/txtQ0015-BETRG”).setFocus
session.findById(“wnd[0]/usr/txtQ0015-BETRG”).caretPosition = 18
session.findById(“wnd[0]”).sendVKey 11

Then you can put this script as VBA macro into MS Excel, handle it in a right manner (i.e. make a cycle) and automate you regular tasks or data upload/ mass change.

Important: scripting doesn’t understand system errors, system messages. eCATT and SAP Personas understand.

Exit mobile version