cancel
Showing results for 
Search instead for 
Did you mean: 

Tips and Tricks: SAP GUI scripting object hierarchy view

stefan_schnell
Active Contributor

Hello community,

a good way to work with the object hierarchy of SAP GUI scripting is to load the file C:\Program Files\SAP\FrontEnd\SAPgui\sapfewse.ocx - this is the SAP GUI scripting API - in the object catalog of Excel or another Office application. Press Alt + F11 to go to VBA. Choose menu Tools > References and press the button Browse to select sapfewse.ocx. Now press F2 to open the object catalog and choose SAPFEWSELib. You see all classes with their elements and types.

Cheers

Stefan

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Mr. Schnell,  I am using VBA to manipulate the tcode ME23N.  In this screen there are multiple tabs, however i am having difficulty ensuring that the screen is on the right tab.  For example, i may be on the delivery schedule tab but i want vba to select that confirmations tab.  Sometimes it works, and sometimes it does not.  Sometimes when i open ME23N, it is already on the confirmations tab and it will give me an error.  Can you provide any guidance?  Thank you.

stefan_schnell
Active Contributor
0 Kudos

Hello Jason,

try this to find a tab with its name:

'-Begin-----------------------------------------------------------------

  If Not IsObject(application) Then
    Set SapGuiAuto = GetObject("SAPGUI")
    Set application = SapGuiAuto.GetScriptingEngine
  End If

  If Not IsObject(connection) Then
    Set connection = application.Children(1)
  End If

  If Not IsObject(session) Then
    Set session = connection.Children(0)
  End If

  For i = 1 To 5
    name = "tabpTABHDT" & CStr(i)
    tab = session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB1:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1102/tabsHEADER_DETAIL/" & name).text
    If tab = "Address" Then
      session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB1:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1102/tabsHEADER_DETAIL/" & name).select
      Exit For
    End If
    Next

'-End-------------------------------------------------------------------

In this example I search for the address tab:

Cheers

Stefan

Former Member
0 Kudos

On this line

saptab = session.FindById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB1:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1102/tabsHEADER_DETAIL/" & Name).Text

i get this error

<The control could not be found by id>

Former Member
0 Kudos

Nevermind, i made a mistake!!

Former Member
0 Kudos

Yes that worked, thank you very much!!

Former Member
0 Kudos

Works! Thank you Stefan!