Skip to Content
0

How to pass a variable containing a string to findById

Mar 09 at 08:35 AM

25

avatar image
Former Member

Hello,

I have the following code that I want to simplify in order to be able to iterate thru a Table.

Original Code

.findById("wnd[0]/usr/tabsTS_ITOV/tabpTCMA/ssubSUBPAGE:SAPLCSDI:0152/tblSAPLCSDITCMAT/ctxtRC29P-IDNRK[2,3]").SetFocus

My New Code

col_item = 2
row_item = 3

table_id = "wnd[0]/usr/tabsTS_ITOV/tabpTCMA/ssubSUBPAGE:SAPLCSDI:0152/tblSAPLCSDITCMAT/ctxtRC29P-IDNRK"

table_item = table_id & "[" & Str(col_item) & "," & Str(row_item) & "]"    'String concatenation to iterate through Table.findById(table_item).SetFocus   

My code stops working when it reaches the .findById(table_item).SetFocus line. It says it can't find ID.

Do you have any recommendations.

Thank you for your help.

Carlos De La Cruz.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Stefan Schnell
Mar 09 at 10:07 AM
0

Hello Carlos,

welcome in the SAP Community.

Your code works, but you must use CStr instead Str. I tried it with another table, here the code:

col_item = 2
row_item = 3
table_id = "wnd[0]/usr/tblSAPMBIBSTC535/txtLOOP510-F3"
table_item = table_id & "[" & CStr(col_item) & "," & CStr(row_item) & "]"
session.findById(table_item).SetFocus

Cheers
Stefan

Share
10 |10000 characters needed characters left characters exceeded