Skip to Content
avatar image
Former Member

FindById method not supported in sap gui scripting

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • avatar image
    Former Member
    Oct 21, 2017 at 07:49 AM

    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
    Add comment
    10|10000 characters needed characters exceeded

  • Oct 22, 2017 at 12:25 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 23, 2017 at 07:48 AM

    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

    Add comment
    10|10000 characters needed characters exceeded