cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

FindById method not supported in sap gui scripting

mser
Explorer
0 Likes
3,110

Hi All,

The following code is not working:

Set children = session.findById("wnd[0]/usr").children 
For each child in children  
  If child.Type = "GuiSimpleContainer" Then    
    child.findById("subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:3212/cntlGRIDCONTROL/shellcont/shell")  
  End if 
Next

I got: Property or method not supported by the object: child.findById.

But child is of type GuiSimpleContainer and as such it must support the findById method

Many thanks

Accepted Solutions (0)

Answers (3)

Answers (3)

mser
Explorer
0 Likes

Hi Stefan,

first of all thanks so much for your answer, I read all your articles on sap gui scripting: you rock !!

I think the problem is not solved with Set. The same code work if I just use FindByName instead of FindById.

I need To begin the search of a component from the user area because in some MM transactions, (ie ME21N, ME51N) you get that the absolute ID changes based on the values on table ESDUS. So you register the transaction with and id and after some time you go back and catch a "The component could not find by id" because something changed in the gui layout due to the dynamic values saved in table esdus. So I need to get the ID of the user area (this is the id that changes) a Runtime and then find its children.

Back to the problem: I'm not a COM expert ( I'm on the java side) but I feel weird that you can say that an interface expose an method and then you can not to fulfill the contract

Stefan-Schnell
Active Contributor
0 Likes

Hello Mascia,

your code looks good, but you want to set an object to a variable, so it is necessary to use Set command.

Here an example:

Set guiComp = session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:3212/cntlGRIDCONTROL/shellcont/shell")
MsgBox guiComp.Text()

This code delivers what expected: SAPGUI.GridViewCtrl.1.

Try it and let us know your result.

If I try the same way as you I get also an error. I don't know why the "detour" about guiCont delivers an error, but if you use the complete Id it works.

Cheers
Stefan

mser
Explorer
0 Likes

I even try in vb

Dim guiCont As GuiSimpleContainer
Dim guiComp As GuiComponent
guiComp = currentSession.FindById("wnd[0]/tbar[0]/okcd")
DirectCast(guiComp, GuiOkCodeField).Text = "/nme51n"
guiComp = currentSession.FindById("wnd[0]")
DirectCast(guiComp, GuiMainWindow).SendVKey(0)
guiCont = currentSession.FindById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013")
guiComp = guiCont.FindById("subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:3212/cntlGRIDCONTROL/shellcont/shell")

I got a COM exception of type Member not found