cancel
Showing results for 
Search instead for 
Did you mean: 

System Message handling help

Former Member
0 Kudos

Hello! I have been using SAP scripts through Excel for about 9 months and have never been able to come up with a solution to the following errors.

1. Whenever our system Admin decides to display a System message for all users when they log in, None of my scripts have the handling of this message included in them, therefore they all result in errors. Was wondering if anybody would enlighten me on how to add this into a script of mine. (located at the end of post) Not sure if the wizard helps or not.

2. I get this notification near the bottom of the screen from time to time which stalls my scripts (I tried adding On error resume next and on error goto 0 in quite a few different places). All I would like to do is add an If that can handle both of these but am not sure where to begin.

Any help would be most appreciated.

Thanks!

My Code:


session.findById("wnd[0]").maximize
session.findById("wnd[0]/usr/txtRSYST-MANDT").Text = "010"
session.findById("wnd[0]/usr/txtRSYST-BNAME").Text = UserBPP
session.findById("wnd[0]/usr/pwdRSYST-BCODE").Text = PassBPP
session.findById("wnd[0]/usr/txtRSYST-LANGU").Text = "EN"
session.findById("wnd[0]/usr/pwdRSYST-BCODE").SetFocus
session.findById("wnd[0]/usr/pwdRSYST-BCODE").caretPosition = 8
session.findById("wnd[0]").sendVKey 0

            If session.Children.Count > 1 Then

               session.findById("wnd[1]/usr/radMULTI_LOGON_OPT1").Select

               session.findById("wnd[1]/usr/radMULTI_LOGON_OPT1").SetFocus

               session.findById("wnd[1]/tbar[0]/btn[0]").press

            End If

Sheets("DO Coding").Select

Count = Sheets("DO Coding").Range("H:H").SpecialCells(xlCellTypeConstants, 23).Cells.Count - 1


session.findById("wnd[0]").maximize

session.findById("wnd[0]/tbar[0]/okcd").Text = "Vl02n"

session.findById("wnd[0]").sendVKey 0


Do Until Count = 0

Range("H40000").End(xlUp).Select


Delivery = Selection.Value

Code = Selection.Offset(0, 1).Value


session.findById("wnd[0]/usr/ctxtLIKP-VBELN").Text = Delivery

session.findById("wnd[0]/usr/ctxtLIKP-VBELN").caretPosition = 8

session.findById("wnd[0]").sendVKey 0

session.findById("wnd[0]").sendVKey 8

session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_HEAD/tabpT\07").Select

session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_HEAD/tabpT\07/ssubSUBSCREEN_BODY:SAPMV50A:2110/txtLIKP-LIFEX").Text = Code

session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_HEAD/tabpT\07/ssubSUBSCREEN_BODY:SAPMV50A:2110/txtLIKP-LIFEX").caretPosition = 4

session.findById("wnd[0]").sendVKey 0

session.findById("wnd[0]/tbar[0]/btn[11]").press


Accepted Solutions (1)

Accepted Solutions (1)

script_man
Active Contributor
0 Kudos

Hi Cory Cox,

Question number 1:


Windows Script Host has only two commands to perform your own error handling.

on error resume next

on error goto 0

The command on error goto ErrorHandler is not allowed.

If you know that now, you could try for example the following construction.

on error resume next

myscript

if err.number <> 0 then

   myErrorHandling

   myscript

   if err.number <> 0 then

      msgbox "There is an unknown error occurred.", vbOKOnly, "Warning"

   end if

end if

sub myscript()

' Here is the code of your current script.

end sub

sub myErrorHandling()

err.clear

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 IsObject(WScript) Then

   WScript.ConnectObject session,     "on"

   WScript.ConnectObject application, "on"

End If

session.findById("wnd[1]/tbar[0]/btn[12]").press

end sub

Question number 2:

Please have a look here:   http://scn.sap.com/thread/851060


Regards,

ScriptMan

Former Member
0 Kudos

Yesterday our system admin displayed a System message on login so I spent quite a few hours yesterday testing the first issue.

What ended up working was placing this script after I check the number of Children in the script

        On Error Resume Next

        If session.findbyId("wnd[1]") = True Then

        session.findbyId("wnd[1]/tbar[0]/btn[12]").Press

        End If

        On Error GoTo 0

However, for my other issue, I'm not trying to figure out what a complete delivery order is. I'm trying to figure out an if statement to handle it when it appears, but because they are very rare occurrences, I haven't been able to test anything. All I need is an if statement to identify that the message has popped up at the bottom. the Then statement would simply be :

session.findbyId("wnd[0]").sendVKey 0

script_man
Active Contributor
0 Kudos

If you do not know where the error occurs, you should use the above construction. Otherwise you can ask directly about the warning exactly at the point in the script where it occurs.

For example:

if session.findById("wnd[0]/sbar").text = "The customer has requested complete delivery" then

  session.findbyId("wnd[0]").sendVKey 0

end if

Former Member
0 Kudos

It is not recognizing when the bar says "The customer has requested complete delivery"

Is there any other possible way to write this, other than:

if session.findById("wnd[0]/sbar").text = "The customer has requested complete delivery"


script_man
Active Contributor
0 Kudos

That's not true.

If you do not used  "on error resume next", then the script will be stop at the point where the message occurs. Right there you must then install the above.

Or add right there the following:

on error resume next

session.findbyId("wnd[0]").sendVKey 0

on error goto 0

Former Member
0 Kudos

If i use the script with "on error resume next" then it gets triggered every time (even for the orders that don't say "The customer has requested complete delivery")  and by it pressing Enter every time, it takes me back into the same order over and over.

Sorry if this is confusing. I hope you understand what I'm trying to accomplish.

This script seems like it should work:

if session.findById("wnd[0]/sbar").text = "The customer has requested complete delivery" then

  session.findbyId("wnd[0]").sendVKey 0

end if

But it still hangs when the message pops up.

I placed the script immediately after I press the save button in the script (which is when the message pops up). I don't think it can go anywhere else but what could be causing it not to recognize that the message is there?

script_man
Active Contributor
0 Kudos

It could be that this message appears with delay. In this case helps e.g. following:

session.findById("wnd[0]/tbar[0]/btn[11]").press

' in Excel-vba

waitTill = Now() + TimeValue("00:00:01")

    While Now() < waitTill

     DoEvents

Wend

' or wscript.sleep 1000 in vb-script

if session.findById("wnd[0]/sbar").text = "The customer has requested complete delivery" then

  session.findbyId("wnd[0]").sendVKey 0

end if

Former Member
0 Kudos

The problem was... that the message pops up as "W: The customer has requested complete delivery".

I didn't have the W: in there. Thank you for all your help regarding this matter, Script Man. Much appreciated

Answers (0)