-1

I am new SAP GUI scripting. I have a question regarding to how to stop SAP GUI script running if there's any status messages captured.

I recently create SAP GUI script recording and Excel macro for automation, so far, everything works very well if there's any data collected. However if there's no data collected and will have status bar then the script will become error.

So I tried to find a way to create some code if the status error show up, the script will automatically close, but seems like I only can make it work if the error is only for "No items selected (see long text)". However there are also other few status error will shown up as well, so I'm thinking to make the status bar captured the whole error if possible.

Hopefully you guys can help me regarding this in SAP GUI scripting,

thanks.

If session.findById("wnd[0]/sbar").Text = "No items selected (see long text)" Then
Exit Sub

End If
sephiroth
  • 43
  • 7
  • Hi, I've modified and put the code which I use for now, but it only works if that status message appear, sometimes can be different message. So i'm trying to make the code captured all type of status message if possible – sephiroth Jan 21 '22 at 03:08

1 Answers1

0

You can check for the messagetype of the status bar. If it is E then you've got an error.

Instead checking for the text like in your code you check for the messagetype

If session.findById("wnd[0]/sbar").MessageType= "E" Then
  ' Whatever code is needed here
Exit Sub

End If
Storax
  • 11,158
  • 3
  • 16
  • 33