When attempting to script out a SAP application I am getting the error "VB:Msg:Object variable or With block variable not set." However, if I put a break point at the Set session = SAPWindow ("Application = SAPLOGON.EXE") the recorder stops the script and pops up in front of the window. When I hit the play button for the script to continue it works as expected. What do I need to add in order for it to work without the break?
Answer by Yuriy L. · Oct 12, 2018 at 03:44 PM
@Nick L.
Hi Nick,
Based upon your description, most likely the script executes the command in
problem before the SAPWindow object
gets created. This is a common
synchronization problem: you do not want your script to be ahead of your
application. So, I think the cure would
be to put a command
WaitForWindow "Application = SAPLOGON.EXE"
in front of the command in problem.
Please post whether or not this helped you to address your problem. If this does not help, please open a support
ticket.
Thank you,
Yuriy
Answer by Nick L. · Oct 12, 2018 at 03:56 PM
It did not help the issue. Below is the script. There is already a wait event above the Set command, though I added the second wait event just to double check.
Sub Main() On Error GoTo ErrorHandler 'Comment/Uncomment these as necessary 'InitAgentDriver Me.Name 'InitAppDriver Me.Name InitChild Me.Name Dim session As Object ' -------------------------------------------------------------------------------------- ' -------------- Launch SAP -------------- 'StartTrace "" ' START vvvvvvvvvvvvv LaunchApp "C:\Program Files (x86)\SAP\FrontEnd\SAPgui\saplogon.exe" WaitForAny "SAP_GUI_Launch" 'Looking for "PROD - ECC" 'StopTimerAndTrace "" ' END ^^^^^^^^^^^^^^^ ' -------------- Launch user session -------------- ShowStatusBox ("Clicking on 'Opening Prod Ecc'...") 'StartTrace "" ' START vvvvvvvvvvvvv Window("Application=SAPLOGON.EXE ClassName='#32770' Caption='SAP Logon 740'").Attach ListView("Parent.Caption=myContainer").Select "DEV - ECC", tpMouseDoubleClick WaitForWindow "Application=SAPLOGON.EXE Caption='SAP Easy Access - User Menu for CVAN02'", DoesExist 'StopTimerAndTrace "" ' END ^^^^^^^^^^^^^^^ ' -------------- Open FB03 -------------- ShowStatusBox ("Opening 'FB03'...") 'StartTrace "" ' START vvvvvvvvvvvvv 'Set session = SAPWindow("Application = SAPLOGON.EXE") WaitForWindow ("Application = SAPLOGON.EXE") Set session = SAPWindow("Application = SAPLOGON.EXE") 'session.Object.findById("wnd[0]").Maximize session.Object.findById("wnd[0]/tbar[0]/okcd").SetFocus session.Object.findById("wnd[0]/tbar[0]/okcd").Text = "fb03" session.Object.findById("wnd[0]/tbar[0]/btn[0]").press
Learn the enhanced capabilities of the next generation Dynatrace AI root cause analysis and how to feed it with your own data sources.
Wednesday, February 20, 2019
Register today!
Learn the enhanced capabilities of the next generation Dynatrace AI root cause analysis and how to feed it with your own data sources.
Wednesday, February 20, 2019
Register today!
Would you like to have an early taste of what we have cooked up for 2019? We would love to hear your feedback and improve some of the new features. Check NAM 2019 Beta release notes.
Sign up today!
Manually marking a transaction unavailable 2 Answers
Sample usage of Whenever for Proxy Login 1 Answer
Activex under SilverLight 3 Answers
Transactions using CMD 3 Answers