cancel
Showing results for 
Search instead for 
Did you mean: 

Search Value in Grid SAP.

Former Member
0 Kudos
293

Good afternoon,

I'm having trouble finding a value in the SAP table, for example, I have the value "11,077,602", I need to fetch it in the SAP table and double click when it finds, can anyone help me with VBS? I could not go ahead as per the code below.

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]").resizeWorkingPane 80,36,false
session.findById("wnd[0]/tbar[0]/okcd").text = "iw33"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtCAUFVD-AUFNR").text = "2016133421"
session.findById("wnd[0]/usr/ctxtCAUFVD-AUFNR").caretPosition = 10
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/subSUB_ALL:SAPLCOIH:3001/ssubSUB_LEVEL:SAPLCOIH:1100/tabsTS_1100/tabpMUEB").select
session.findById("wnd[0]/usr/subSUB_ALL:SAPLCOIH:3001/ssubSUB_LEVEL:SAPLCOIH:1107/tabsTS_1100/tabpMUEB/ssubSUB_AUFTRAG:SAPLCOMK:3020/tblSAPLCOMKTCTRL_3020/ctxtRESBD-MATNR[1,0]")

dim sapRow

sapRow = 0

Set GRID1 = session.FindById("wnd[0]/usr/subSUB_ALL:SAPLCOIH:3001/ssubSUB_LEVEL:SAPLCOIH:1107/tabsTS_1100/tabpMUEB/ssubSUB_AUFTRAG:SAPLCOMK:3020/tblSAPLCOMKTCTRL_3020")

sapRow = GRID1.rowCount - 1

For sapRow = 0 to GRID1.rowCount - 1

'run row

next

Accepted Solutions (0)

Answers (1)

Answers (1)

script_man
Active Contributor
0 Kudos

Hi Alef,

one possible solution might look like this:


. . .
session.findById("wnd[0]/usr/subSUB_ALL:SAPLCOIH:3001/ssubSUB_LEVEL:SAPLCOIH:1100/tabsTS_1100/tabpMUEB").select
'dim sapRow
'sapRow = 0

myVariable = "11.077.602"

do
 set myTable = session.findById("wnd[0]/usr/subSUB_ALL:SAPLCOIH:3001/ssubSUB_LEVEL:SAPLCOIH:1107/tabsTS_1100/tabpMUEB/ssubSUB_AUFTRAG:SAPLCOMK:3020/tblSAPLCOMKTCTRL_3020")

 rows = myTable.RowCount
 cols = myTable.Columns.Count
 vRows = myTable.VisibleRowCount
 

 for i = 0 to vRows - 1
     on error resume next
     myCell = trim(myTable.GetCell(i,1).Text) 
     if err.number <> 0 then  exit for      
     on error goto 0
     if myCell = myVariable then 
        session.findById("wnd[0]").sendVkey 2
        exit for
     end if
 next
 if err.number <> 0 or myCell = myVariable then  exit do       
 myTable.VerticalScrollbar.Position = myTable.VerticalScrollbar.Position + vRows
Loop 

Regards,

ScriptMan