question

Nick L. avatar image
Nick L. asked ·

SAP playback error with Agent Recorder

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?

esm
10 |2000000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 50.0 MiB each and 250.0 MiB total.

Yuriy L. avatar image
Yuriy L. answered ·

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

Share
10 |2000000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 50.0 MiB each and 250.0 MiB total.

Nick L. avatar image
Nick L. answered ·

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

Share
10 |2000000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 50.0 MiB each and 250.0 MiB total.

Yuriy L. avatar image
Yuriy L. answered ·

@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

Share
10 |2000000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 50.0 MiB each and 250.0 MiB total.