1

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

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, it varies the rows available.

Sometimes there will be :

0100, 0110, 0120, 0121, 0122, 0123, 0124, 0125, 0130, 0140
-sometimes there will be 0100, 0110, 0122, 0123, 0124, 0125, 0140
-sometimes there will be 0100, 0121, 0122, 0123, 0124, 0125, 0140
-sometimes there will be 0100, 0122, 0123, 0125, 0130, 0140
etc

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
            msgbox "row = " & row " & " is 0122"
         end if
         if readVariable = 0125
            msgbox "row = " & row " & " is 0125"
         end if
next

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

Thanks a lot!!!

enter image description here

Suncatcher
  • 10,355
  • 10
  • 52
  • 90
Eduardo GS
  • 33
  • 1
  • 7
  • 1
    With the recorder, if you position the caret (text cursor) in the field, at the 1st character for instance, the generated VBS file will contain something like `session.findById("").caretPosition = 1` and so your own VBS can use this ID: `msgbox session.findById("").text` – Sandra Rossi Dec 19 '19 at 18:00
  • Thanks a million, Sandra Rossi! It worked! It reads "0110". Comparing msgbox *** = 0110, msgbox *** = 110 and msgbox *** = "0110" return TRUE (only msgbox *** = "110" returns FALSE). Thanks! Is it recognized as a VALUE, right? Because msgbox *** + 1 returns 111. How do I read it as an string? @SandraRossi – Eduardo GS Dec 19 '19 at 18:33
  • The property `text` is always a String. Adding 1 implies a type conversion, as per the VBScript type model, I guess. – Sandra Rossi Dec 20 '19 at 15:52
  • I have written an [extensive answer about how to work with Table Controls](https://stackoverflow.com/a/68715008/9150270), which also contains the answer in this question. – Sandra Rossi Aug 10 '21 at 07:18

1 Answers1

1

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.