cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SAP playback error with Agent Recorder

nick_larson
Newcomer

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?


3 REPLIES 3

yuriy_look
Inactive

@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


nick_larson
Newcomer

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


yuriy_look
Inactive

Please open a support ticket. It's necessary to do some experiments.