cancel
Showing results for 
Search instead for 
Did you mean: 

VBA Script not capturing SAP session message

Former Member
0 Kudos

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.

Thanks

Jim


For G = 0 to 10

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

Next

Accepted Solutions (1)

Accepted Solutions (1)

script_man
Active Contributor
0 Kudos

My suggestion:

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

Regards,

ScriptMan

Former Member
0 Kudos

Hi Script.man,

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]").maximize
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]").SetFocus
session.findById("wnd[0]/usr/txt[34,12]").caretPosition = 2
session.findById("wnd[0]").sendVKey 8
session.findById("wnd[1]/tbar[0]/btn[12]").press
session.findById("wnd[0]").sendVKey 3
session.findById("wnd[0]").sendVKey 8
x = x + 1
Next i
End Sub

Thanks

Stephan

Former Member
0 Kudos

how Can i contact you directly?

Answers (1)

Answers (1)

Former Member
0 Kudos

Thank you Script Man.