cancel
Showing results for 
Search instead for 
Did you mean: 

How can i Capture the status bar from SAP using Excel VBScript

Former Member
0 Kudos

in this case i have a License missing code

the message type should be "E"

and it still gose to NO ERROR on the if condition

if session.findById("wnd[0]/sbar").text= "E" then
MSGBOX "ERROR"
else
MSGBOX "NO ERROR"
end if

i want to be able to identify when there's an error on the Status BAR so i can stop the macro and fix that error manually, but i'm not able to get the message type or text.

The message type indicates the seriousness of a message and is visualized by an icon.

Stop: A Cancel

Red: E Error

Yellow: W Warning

Green: I/S Information/success message

no matter what message type i put in the IF condition it will always go to the "NO ERROR " MSGBOX

Former Member

Hello Matt

i appreciate your help

and yea i'm new at this, i just started looking into macros that run in SAP threw VBA SCRIPTING.

there still alot of things i dont understand understand from SAP

there alot of things i dont know how to do,

once again thanks for your help

Cheers

Accepted Solutions (1)

Accepted Solutions (1)

stefan_schnell
Active Contributor

Hello Andrew,

you can read the MessageType:

    If Not IsObject(application) Then
      Set SapGuiAuto = GetObject("SAPGUI")
      Set application = SapGuiAuto.GetScriptingEngine
    End If

    If Not IsObject(connection) Then
      Set connection = application.Children(0)
    End If

    If Not IsObject(session) Then
      Set session = connection.Children(0)
    End If

    If session.findById("wnd[0]/sbar").MessageType = "E" Then
      'Your code here
    End If 

S = Success, W = Warning, E = Error, A = Abort and I = Information

Let us know your result.

Cheers
Stefan

Former Member
0 Kudos

Hello Stefan,

thank you for your help

i tried it already, but it doesn't seem to work,

i tryed it with all message types: S = Success, W = Warning, E = Error, A = Abort and I = Information

and it will go to "no error"

If session.findById("wnd[0]/sbar").MessageType = "E" Then    

     MsgBox " ERROR"

Else
     MsgBox " NO ERROR

"EndIf

i tryed saving the message type in a variable to print it in an excel sheet but it turns out beeing empty.

MT = session.findById("wnd[0]/sbar").MessageTypeRange

("A2").value= MT 

'i also tried
Range("A2").text= MT
Former Member
0 Kudos

in this case i have a License missing error.

the message type in this case is "E"

If session.findById("wnd[0]/sbar").MessageType = "E" Then    

     MsgBox " ERROR"

Else
  
   MsgBox " NO ERROR"

EndIf

when i run my code it will still go to NO ERROR

Former Member
0 Kudos

this is how it looks when ther is no error.

Answers (3)

Answers (3)

stefan_schnell
Active Contributor

Hello Andrew,

sorry, but in our systems is the software component Global Trade Services not available, so I can't trace it direct.

I use as example the SE80 with an error.

It has a splitter, like in your case, and a table beneath. The table is in this case a GridView. Is it possible for you to use Scripting Tracker to analyze your UI?

Cheers
Stefan

Former Member
0 Kudos

thank you for that, i see in my case its a Grindview aswell

stefan_schnell
Active Contributor

Hello Andrew,

thanks for your reply. As far as I can see you don't want to read status bar, it seems that it is a table. Which transaction code do you use? Please describe your proceeding until you get the table with the error entries. So I can retrace your way.

Cheers
Stefan

Former Member
0 Kudos

transaction code: /SAPSLL/CUS_SGL02

stefan_schnell
Active Contributor
0 Kudos

Hello Andrew,

thanks for your reply. Good to hear the news, now you can get your messages.

Cheers
Stefan