Skip to Content

Calling R/3 workflow monitor from Excel

I need to create an Excel to-do/ task tracking spreadsheet. As part of this, I want them to be able to click a link or run a macro to open the SAP R/3 workflow monitor whether they are already logged in or not. I have virtually no experience in VBA. I already added excel.exe to the SAP GUI configuration and have SAP controls in Excel. Can you help me with a script or suggestions on how to do this?

Add comment
10|10000 characters needed characters exceeded

  • I found this script in another reply from the archives and modified it for the workflow transaction. However, when I try to run it I get "Runtime error 70: Permission denied".

    Sub WFMonitor()
    If Not IsObject(SAPguiApp) Then
    Set SAPguiApp = CreateObject("Sapgui.ScriptingCtrl.1")
    End If
    If Not IsObject(Connection) Then
    Set Connection = SAPguiApp.OpenConnection("SYSTEMNAME", True)
    End If
    If Not IsObject(session) Then
    Set session = Connection.Children(0)
    End If
    session.findById("wnd[0]/usr/txtRSYST-MANDT").Text = "123" session.findById("wnd[0]/usr/txtRSYST-BNAME").Text = "USER" session.findById("wnd[0]/usr/pwdRSYST-BCODE").Text = "PASSWORD" session.findById("wnd[0]/usr/txtRSYST-LANGU").Text = "EN" session.findById("wnd[0]/usr/txtRSYST-LANGU").SetFocus session.findById("wnd[0]/usr/txtRSYST-LANGU").caretPosition = 2 session.findById("wnd[0]").sendVKey 0
    . . .
    session.findById("wnd[0]/tbar[0]/okcd").Text = "/nzsps_wf_monitor03" session.findById("wnd[0]").sendVKey 0 session.findById("wnd[0]").maximize

    MsgBox "If you click on the OK button, the SAP session is terminated."
    End Sub

  • Get RSS Feed

4 Answers

  • Best Answer
    May 23, 2017 at 10:47 PM

    Interesting request. It depends a little on your security requirements, but I would go about this completely from the other end - partly due to lack of know-how on VBA-SAP integration :-)

    If at least some of the data is not critically sensitive, expose it as a web service or callable as an RFC. More coding in SAP and less in VBA, but at least you would be creating a standard interface that can be reused in different scenarios. In other words, you write the equivalent of a BAPI function that gives you all the monitor data. From Excel/VBA you can query it either via RFC call or by HTTP/S and display it as you like in Excel.

    Add comment
    10|10000 characters needed characters exceeded

    • Thank you, Mike. Since our security permissions are so tight, I believe you are correct and this is the best way to go. I'll probably hand it over to our IT department and have them create it for me. :-)

  • May 22, 2017 at 07:54 AM

    Hi Jenny,

    Probably the answer to your issue of not able to connect can be found here.

    Thanks, Pavan

    Add comment
    10|10000 characters needed characters exceeded

    • Thank you, Pavan. Unfortunately, the script found in the link did not work, either. I am beginning to suspect that our corporate security is preventing me from creating the script I need. I tried to run RZ11 to see if scripting was enable and was denied access to that transaction. I also tried copying the script into Excel as a VBA project and got a Compile error: Syntax error. This is the script that I copied:

      PrivateSub CommandButton1_Click()
      Dim SapGui AsObject
      Dim saplogon AsObject
      Dim connection 'As Object
      Set SapGui = GetObject("SAPGUI")
      Dim Wshshell AsObject
      Set Wshshell = CreateObject("Wscript.Shell")
      Wshshell.Run Chr(34)&("C:\Program Files\SAPPC\FrontEnd\SAPgui \saplogon.exe")& Chr(34)&" "&"/INI_FILE"&"="& Chr(34)&"\\longpathtoini\appl\Sap\saplogon\int\saplogon.ini"& Chr(34)
      DoUntil Wshshell.AppActivate("SAP Logon")
      Application.Wait Now + TimeValue("0:00:01")
      Set Wshell =Nothing
      Set saplogon = SapGui.GetScriptingEngine
      connection = SapGui.OpenConnection("SID",True)
      Set SapGui =Nothing
      Set saplogon =Nothing
      Set connection =Nothing
  • May 22, 2017 at 07:51 AM

    Hi JK,

    on the requirement, what do you mean by 'to open the SAP R/3 workflow monitor' ?

    Could you elaborate please.

    Aditya V

    Add comment
    10|10000 characters needed characters exceeded

  • May 24, 2017 at 09:35 PM

    Many thanks to all of you for your input, instructions and insights!

    Add comment
    10|10000 characters needed characters exceeded