SAP script error checking

Hi,

When a command is send to SAP like “SAPsession.FindById(“wnd[0]”).resizeWorkingPane(170, 25, False)” and an error occurs I’d like to log the error and let the script continue after user input (if needed) to fix the error. Next I want to use the Log to examine the errors and fix them.

I was thinking to do this via an additional sub that handles the sap command and catches the error like this:

****************************************************************

Private sub resize() ‘SAPCommand to be executed

SAPCommand(SAPsession.FindById(“wnd[0]”).resizeWorkingPane(170, 25, False))
SAPCommand(SAPsession.FindById(“wnd[0]/tbar[0]/okcd”).text = “/nsu3”)
SAPCommand(SAPsession.FindById(“wnd[0]”).sendVKey(0))

End Sub

 

Private sub SAPCommand(input)         ‘//SAPCommand to be executed

try
    Run SAPCommand
Catch ex as Exception
    Log(“Error for: ” & input & vbCRLF & ex.tostring)
    msgbox(“Fix the error for command: ” & input)
end try

end sub

****************************************************************

I know the above code does not workout at all but it’s just for illustration of what I’d like to accomplish.

Thanks!

 

Scroll to Top