Skip to Content

VBA Script not capturing SAP session message

Oct 24, 2016 at 03:06 AM


avatar image
Former Member

Hell team,

When i am trying to use below piece of code. It is not taking value from SAP.

When i am using g loop for getting value from SAP. it is not capturing. could you please advise. where i need to change.



For G = 0 to 10

AHOUR = session.findById("wnd[0]/usr/subSUB:SAPLK23D:0200/tblSAPLK23DTABLE/txtCONTRLLINE-LSTBTR[6,G]").Text

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Script Man Oct 25, 2016 at 06:09 AM

My suggestion:

AHOUR = session.findById("wnd[0]/usr/subSUB:SAPLK23D:0200/tblSAPLK23DTABLE/txtCONTRLLINE-LSTBTR[6," & cstr(G) & "]").Text



Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member


I have an issue. Could you help me with this here:

I have recorded the Transaction call SE37 and FM "RECA_GUI_TEXTEDIT_POPUP" buth when it Comes to the popup with the needed thext and I click on save to local hdd it works well, but not shown in the script coding. Could you please help me to get the right Statement to define my own save Folder and file Name? Or how Can I use copy and paste from/to clipboard. I have added the script code into my Excel to use also a macro as seen below. Please help me!

Set SapGuiAuto = GetObject("SAPGUI") 'Get the SAP GUI Scripting object
Set SAPApp = SapGuiAuto.GetScriptingEngine 'Get the currently running SAP GUI
Set SAPCon = SAPApp.Children(0) 'Get the first system that is currently connected
Set session = SAPCon.Children(0) 'Get the first session (window) on that connection

On Error Resume Next

If Not IsObject(Application) Then
Set SapGuiAuto = GetObject("SAPGUI")
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

x = 2
For i = 1 To 2
session.findById("wnd[0]/tbar[0]/okcd").Text = "se37"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtRS38L-NAME").Text = "RECA_GUI_TEXTEDIT_POPUP"
session.findById("wnd[0]").sendVKey 8
session.findById("wnd[0]/usr/txt[34,8]").Text = "ROUTING"
session.findById("wnd[0]/usr/txt[34,9]").Text = "010N100882250000000100000007"
session.findById("wnd[0]/usr/txt[34,10]").Text = "PLPO"
session.findById("wnd[0]/usr/txt[34,11]").Text = "EN"
session.findById("wnd[0]/usr/txt[34,12]").Text = "03"
session.findById("wnd[0]/usr/txt[34,12]").caretPosition = 2
session.findById("wnd[0]").sendVKey 8
session.findById("wnd[0]").sendVKey 3
session.findById("wnd[0]").sendVKey 8
x = x + 1
Next i
End Sub



Former Member

how Can i contact you directly?

avatar image
Former Member Oct 26, 2016 at 05:12 PM

Thank you Script Man.

10 |10000 characters needed characters left characters exceeded