vbascriptingsap-gui

How to read the cell value in a table control?


I want to read a cell value on a table - example on transaction C202:

SAP GUI transaction `C202`

I can use SAP GUI Scripting Recorder to "check" or "select" (row = 5, column = 1), which is next to "0122" and (row = 5, column = 1), which is next to "0125", it gives me a simple code:

' selects 0122
session.findById("wnd[0]/usr/tabsTABSTRIP_RECIPE/tabpVOUE/ssubSUBSCREEN_RECIPE:SAPLCPDI:4401/tblSAPLCPDITCTRL_4401").getAbsoluteRow(4).selected = true

'selects 0125
session.findById("wnd[0]/usr/tabsTABSTRIP_RECIPE/tabpVOUE/ssubSUBSCREEN_RECIPE:SAPLCPDI:4401/tblSAPLCPDITCTRL_4401").getAbsoluteRow(7).selected = true

However, the row containing 0122 or 0125 is at a different row. The rows could be different e.g.:

I want to read column = 2 so I know if it's 0122 or 0125 and then check them.

How could I put this value inside a variable and use msgbox to display it?

PSEUDO CODE:

dim readVariable as string

for row = 1 to NumberOfRows
      readVariable = Table.Read (row,2) ' <======== ???
         if readVariable = 0122 then
            msgbox "row = " & row " & " is 0122"
         end if
         if readVariable = 0125 then
            msgbox "row = " & row " & " is 0125"
         end if
next

I tried following Link but I can't get it to work.

Thanks a lot!!!


Solution

  • Use '&' instead of a + and you'll get 01101 as VBS will assume that the conversion will be directed to string type and will concat your string with "1" instead of parsing your string to digit type of variable to simply add 1.