on 07-05-2012 10:51 AM
Dear Experts,
We are trying to connect the SAP BW logon through an excel macro. We are unable to connect thru the macro. The logon pad opens but iwe are not able to furnish the user name and password in the logon screen automatically. Also a debug message pops up in the excel macro at :
Set session = Connection.Children (0)
When debugged we get Session = empty as the message.
Below we have pasted the code used .
Sub sapmicro()
If Not IsObject(SAPguiApp) Then
Set SAPguiApp = CreateObject("Sapgui.ScriptingCtrl.1")
End If
If Not IsObject(Connection) Then
Set Connection = SAPguiApp.OpenConnection("KPBI DPW - Project Track Global SAP BI Development", True)
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[0]").maximize
session.findById("wnd[0]/usr/txtRSYST-MANDT").Text = "009"
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/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_OPT2").Select
session.findById("wnd[1]/usr/radMULTI_LOGON_OPT2").SetFocus
session.findById("wnd[1]/tbar[0]/btn[0]").press
End If
End Sub
Hi rajarathnam S,
I was able to run your code without problems. If the Excel-Macro is completed, the SAP session is closed. Try to install the following command at the end of your macro.
for example:
...
MsgBox "If you click on the OK button, the SAP session is terminated."
End Sub
Regards,
ScriptMan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello rajarathnam S,
please have a look at http://scn.sap.com/thread/2142369
Maybe this helps.
Bye, netkid
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.