cancel
Showing results for 
Search instead for 
Did you mean: 

Calling R/3 workflow monitor from Excel

Former Member
0 Kudos

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?

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

pokrakam
Active Contributor
0 Kudos

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.

Former Member
0 Kudos

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. 🙂

Answers (3)

Answers (3)

Former Member
0 Kudos

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

bpawanchand
Active Contributor
0 Kudos

Hi Jenny,

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

Thanks, Pavan

Former Member
0 Kudos

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")
Loop
Set Wshell =Nothing
Set saplogon = SapGui.GetScriptingEngine
connection = SapGui.OpenConnection("SID",True)
Set SapGui =Nothing
Set saplogon =Nothing
Set connection =Nothing
EndSub
former_member184495
Active Contributor
0 Kudos

Hi JK,

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

Could you elaborate please.

Aditya V

Former Member
0 Kudos

Hello Aditya,

I need to create an Excel (VBA) link, script, macro, command - whatever - within the Excel spreadsheet that will automatically open with workflow monitor so the Developer can enter the material code and see the current workflow status. I am not sure anything will work, at this point. Our security may be set too tight.

I tried to run the RZ11 transaction in SAP to see if scripting was enabled, in case I could create this with VBS, but was denied access to the transaction. Any help or suggestions would be greatly appreciated.

Thank you!

former_member184495
Active Contributor
0 Kudos

hi JK,

tough for me, sorry cant help you at this point of time. Hope you get tips from our experts.

Aditya V