Skip to content

efeumutaslan/SAP-SKILLS / skills/sap-gui-scripting

sap-gui-scripting

Verified

SAP GUI Scripting automation skill. Use when automating SAP GUI transactions with VBScript or Python, recording/replaying scripts, batch data entry, or screen scraping SAP screens. If the user mentions SAP GUI automation, GUI scripting, VBScript for SAP, transaction recording, or RPA with SAP GUI, use this skill.

FileKindSize
SKILL.mdskill md11.4 KB
templates/gui-script-template.vbsother3.0 KB

templates/gui-script-template.vbs

View on GitHub
' SAP GUI Scripting — VBScript Template
' Replace: {{TRANSACTION}}, {{FIELD_VALUES}}, {{OUTPUT_PATH}}
' Prerequisites: SAP GUI Scripting enabled on client and server

' ============================================================
' Connection Setup
' ============================================================
If Not IsObject(application) Then
  Set SapGuiAuto = GetObject("SAPGUI")
  Set application = SapGuiAuto.GetScriptingEngine
End If
Set connection = application.Children(0)
Set session = connection.Children(0)

' ============================================================
' Navigate to Transaction
' ============================================================
session.findById("wnd[0]/tbar[0]/okcd").text = "/n{{TRANSACTION}}"
session.findById("wnd[0]").sendVKey 0  ' Enter

' ============================================================
' Fill Screen Fields
' ============================================================
' Text field
session.findById("wnd[0]/usr/ctxtS_BUKRS-LOW").text = "{{COMPANY_CODE}}"

' Date range
session.findById("wnd[0]/usr/ctxtS_BUDAT-LOW").text = "{{DATE_FROM}}"
session.findById("wnd[0]/usr/ctxtS_BUDAT-HIGH").text = "{{DATE_TO}}"

' Checkbox
session.findById("wnd[0]/usr/chkP_TEST").selected = True

' Radio button
session.findById("wnd[0]/usr/radRB_LIST").select

' Dropdown / combo box
session.findById("wnd[0]/usr/cmbP_LAYOUT").key = "{{LAYOUT_VARIANT}}"

' ============================================================
' Execute
' ============================================================
session.findById("wnd[0]/tbar[1]/btn[8]").press  ' F8 = Execute

' ============================================================
' Handle Popups
' ============================================================
On Error Resume Next
Set popup = session.findById("wnd[1]")
If Not popup Is Nothing Then
  ' Check if it's an info popup
  If InStr(popup.text, "Information") > 0 Then
    popup.sendVKey 0  ' Enter to dismiss
  End If
End If
On Error GoTo 0

' ============================================================
' Export ALV Grid to Excel
' ============================================================
' Method 1: Spreadsheet export
session.findById("wnd[0]/mbar/menu[0]/menu[1]/menu[2]").select  ' List > Export > Spreadsheet
session.findById("wnd[1]/usr/ctxtDY_PATH").text = "{{OUTPUT_PATH}}"
session.findById("wnd[1]/usr/ctxtDY_FILENAME").text = "export.xlsx"
session.findById("wnd[1]/tbar[0]/btn[11]").press  ' Replace if exists

' Method 2: Read ALV grid cells programmatically
Set grid = session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell")
Dim rowCount : rowCount = grid.RowCount
Dim colCount : colCount = grid.ColumnCount

For row = 0 To rowCount - 1
  For col = 0 To colCount - 1
    cellValue = grid.GetCellValue(row, grid.ColumnOrder(col))
    ' Process cellValue...
  Next
Next

' ============================================================
' Cleanup
' ============================================================
session.findById("wnd[0]/tbar[0]/okcd").text = "/n"
session.findById("wnd[0]").sendVKey 0

MsgBox "Script completed.", vbInformation, "SAP GUI Script"
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall