cancel
Showing results for 
Search instead for 
Did you mean: 

Reading grid cells (SAP GUI Scripting - VBS)

Former Member
0 Kudos
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
dim sapRow
sapRow = 0
Set GRID1 = session.FindById("wnd[0]/usr/cntlGRID1/shellcont/shell")
'session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").currentCellRow = 9
For sapRow = 0 to GRID1.rowCount - 1
'on error resume next
Value = GRID1.GetCellValue(sapRow,"Notification") - I  get an error on this line
next
Good Day!

I am trying to learn SAP Scripting to automate some of the tasks that we have in SAP.

I want to read grid cells and to check if there is an existing notification in SAP based on the description of each notification. I am getting an error when I try to do a loop to check each available row for any matches. I am not sure on how to store the content of the Notification column into a variable. Any help would be appreciated.

Thank you.

Accepted Solutions (0)

Answers (2)

Answers (2)

stefan_schnell
Active Contributor
0 Kudos

Hello Nicolas,

welcome here in the forum.

I wrote a blog about this requirement, you can find it here. With the solution I described you can read any grid and get the content of each cell.

Let us know your results.

Cheers
Stefan

script_man
Active Contributor
0 Kudos

Hi Nicolas,

it might be that the internal column name is quite different. But you can get it out. For example, you can use the script recorder to record a sort for that column. The name you are looking for is then in the script.

Regards,

ScriptMan