Reputation: 660
I'm looking for a solution how to read text from SAP table.
I can select specific cell in table, but don't know the reference to get its text value.
Below code works fine but what I need is instead of selectItem
I need to get text from this item.
Relevant part of code :
Dim SapGuiAuto, SAP, Connection, Session
If Not IsObject(SAP) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set SAP = SapGuiAuto.GetScriptingEngine
Set Connection = SAP.Children(0)
Set Session = Connection.Children(0)
End If
ReDim ArrSap(1 To 1, 1 To 1)
Session.findById("wnd[0]/shellcont[0]/shell/shellcont[1]/shell[0]").pressButton "MATE"
Session.findById("wnd[0]").iconify
On Error Resume Next
For i = 1 To 999
Select Case i
Case Is > 99
Case Is > 99
Session.findById("wnd[0]/shellcont[0]/shell/shellcont[1]/shell[1]").selectItem " " & i & "", "C 10"
Session.findById("wnd[0]/shellcont[0]/shell/shellcont[1]/shell[1]").expandNode " " & i & ""
Case Is > 9
Session.findById("wnd[0]/shellcont[0]/shell/shellcont[1]/shell[1]").selectItem " " & i & "", "C 10"
Session.findById("wnd[0]/shellcont[0]/shell/shellcont[1]/shell[1]").expandNode " " & i & ""
Case Else
Session.findById("wnd[0]/shellcont[0]/shell/shellcont[1]/shell[1]").selectItem " " & i & "", "C 10"
Session.findById("wnd[0]/shellcont[0]/shell/shellcont[1]/shell[1]").expandNode " " & i & ""
End Select
Next i
Upvotes: 0
Views: 756
Reputation: 1625
A faster solution might look like this:
...
set myTree = Session.findById("wnd[0]/shellcont[0]/shell/shellcont[1]/shell[1]")
For i = 1 To 999
myTree.selectItem right(space(10) & cstr(i),11) , "C 10"
myTree.expandNode right(space(10) & cstr(i),11)
myText = myTree.getItemText (right(space(10) & cstr(i),11) , "C 10")
msgbox myText
Next i
Regards, ScriptMan
Upvotes: 1
Reputation: 1625
I know a workaround.
for example:
...
For i = 1 To 999
Session.findById("wnd[0]/shellcont[0]/shell/shellcont[1]/shell[1]").selectItem right(space(10) & cstr(i),11) , "C 10"
Session.findById("wnd[0]/shellcont[0]/shell/shellcont[1]/shell[1]").expandNode right(space(10) & cstr(i),11)
session.findById("wnd[0]/shellcont[0]/shell/shellcont[1]/shell[1]").itemContextMenu right(space(10) & cstr(i),11) , "C 10"
session.findById("wnd[0]/shellcont[0]/shell/shellcont[1]/shell[1]").selectContextMenuItem "&FIND"
myText = session.findById("wnd[1]/usr/txtLVC_S_SEA-STRING").text
session.findById("wnd[1]/tbar[0]/btn[12]").press
msgbox myText
Next i
Regards, ScriptMan
Upvotes: 1