on 02-17-2016 3:29 PM
Hello everybody,
ME21N have three buttons to show/hide some areas.
I would like to know if is possible to make a test like:
IF button is pressioned (area hidden) Then click to show it
Thanks
Hello André,
welcome in the Scripting Language forum.
Here an example how to solve your problem:
'-Begin-----------------------------------------------------------------
'-Directives----------------------------------------------------------
Option Explicit
'-Function getSimpleContainer-----------------------------------------
'-
'- Function to get the simple container object, which contains the
'- the buttons
'-
'---------------------------------------------------------------------
Function getSimpleContainer(session)
'-Variables-------------------------------------------------------
Dim SimpleContainer
On Error Resume Next
Set SimpleContainer = session.FindById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013")
If Not IsObject(SimpleContainer) Then
Set SimpleContainer = session.FindById("wnd[0]/usr/subSUB0:SAPLMEGUI:0016")
End If
On Error Goto 0
Set getSimpleContainer = SimpleContainer
End Function
'-Sub Main------------------------------------------------------------
Sub Main()
'-Variables-------------------------------------------------------
Dim SapGuiAuto, application, connection, session
Dim SimpleContainer, btnHeader, btnItemOver, btnItem
If Not IsObject(application) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set application = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(connection) Then
Set connection = application.Children(0)
End If
If Not IsObject(session) Then
Set session = connection.Children(0)
End If
'-Check the header button and press it if necessary---------------
Set SimpleContainer = getSimpleContainer(session)
Set btnHeader = session.FindById(SimpleContainer.ID & _
"/subSUB1:SAPLMEVIEWS:1100/subSUB1:SAPLMEVIEWS:4000/btnDYN_4000-BUTTON")
If btnHeader.IconName = "DAAREX" Then
btnHeader.press
End If
'-Check the itemover button and press it if necessary-------------
Set SimpleContainer = getSimpleContainer(session)
Set btnItemOver = session.FindById(SimpleContainer.ID & _
"/subSUB2:SAPLMEVIEWS:1100/subSUB1:SAPLMEVIEWS:4001/btnDYN_4000-BUTTON")
If btnItemOver.IconName = "DAAREX" Then
btnItemOver.press
End If
'-Check the item button and press it if necessary-----------------
Set SimpleContainer = getSimpleContainer(session)
Set btnItem = session.FindById(SimpleContainer.ID & _
"/subSUB3:SAPLMEVIEWS:1100/subSUB1:SAPLMEVIEWS:4002/btnDYN_4000-BUTTON")
If btnItem.IconName = "DAAREX" Then
btnItem.press
End If
End Sub
'-Main----------------------------------------------------------------
Main
'-End-------------------------------------------------------------------
I get the status of the button via the icon in the button, it differs whether it is open or closed.
With each button press the simple container, which containes all elements, changes its ID. So is it necessary to detect the name of the simple container after each button press.
Let us know your results.
Cheers
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.