Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

SAP GUI Scripting - Update Customer Block (XD05)

0 Likes
1,175

Team,

I am new the GUI Scripting.

Requirement customer block :

SAP 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 = "XD05"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtRF02D-KUNNR").text = "9000018"
session.findById("wnd[0]/usr/ctxtRF02D-BUKRS").text = "1000"
session.findById("wnd[0]/usr/ctxtRF02D-VKORG").text = "1000"
session.findById("wnd[0]/usr/ctxtRF02D-VTWEG").text = "10"
session.findById("wnd[0]/usr/ctxtRF02D-SPART").text = "00"
session.findById("wnd[0]/usr/ctxtRF02D-SPART").setFocus
session.findById("wnd[0]/usr/ctxtRF02D-SPART").caretPosition = 2
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtKNA1-AUFSD").text = "01"
session.findById("wnd[0]/usr/ctxtKNVV-AUFSD").text = "01"
session.findById("wnd[0]/usr/ctxtKNVV-AUFSD").setFocus
session.findById("wnd[0]/usr/ctxtKNVV-AUFSD").caretPosition = 2
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/tbar[0]/btn[11]").press


Excel file follows.

How to achieve the above with vba code .

Team,

I am new the GUI Scripting.

Requirement customer block :

SAP 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 = "XD05"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtRF02D-KUNNR").text = "9000018"
session.findById("wnd[0]/usr/ctxtRF02D-BUKRS").text = "1000"
session.findById("wnd[0]/usr/ctxtRF02D-VKORG").text = "1000"
session.findById("wnd[0]/usr/ctxtRF02D-VTWEG").text = "10"
session.findById("wnd[0]/usr/ctxtRF02D-SPART").text = "00"
session.findById("wnd[0]/usr/ctxtRF02D-SPART").setFocus
session.findById("wnd[0]/usr/ctxtRF02D-SPART").caretPosition = 2
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtKNA1-AUFSD").text = "01"
session.findById("wnd[0]/usr/ctxtKNVV-AUFSD").text = "01"
session.findById("wnd[0]/usr/ctxtKNVV-AUFSD").setFocus
session.findById("wnd[0]/usr/ctxtKNVV-AUFSD").caretPosition = 2
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/tbar[0]/btn[11]").press


Excel file follows.

How to achieve the above with vba code .

1 REPLY 1
Read only

Sandra_Rossi
Active Contributor
879

It's unrelated to ABAP, better use the tag UI SAP GUI For Windows, although it's a pure Excel/VBScript question, that you should better ask in a Microsoft VBScript forum.

But first of all, it's very easy to use the Excel macro recorder, which produces VBA code. After that, you manually adapt it to become VBScript.

If you need answers for precise questions, you can search the Web, there are so many useful help sites.