on 09-20-2010 9:06 AM
Hi,
Can Anyone Suggest and help me to do above Code in Excel,"Using Macro in Excel How to open SAP directly"
Example: I want to Open T.CODE: MM01 directly, without login in to SAP, Using Macro, i want to open SAP Directly, Anyone Suggest me how to do it?.............
I Tried this But it showing Run time Error'438', Object does not support this property or method........
VBCODE:
Dim sap As Object
Dim conn As Object
Sub T_login()
Set sap = CreateObject("SAP.Functions")
Set conn = sap.Connection
conn.System = "production"
conn.client = "800"
conn.user = "SAPUSER"
conn.Password = "123456"
conn.Language = ""
conn.Tcode = "MM01"
If conn.logon(0, False) Then
MsgBox "Logon to the SAP system is not possible", vbOKOnly, "Comment"
Else
End If
If Not IsObject(SapGuiApp) Then
Set SapGuiApp = CreateObject("Sapgui.ScriptingCtrl.1")
End If
If Not IsObject(Connection) Then
Set Connection = SapGuiApp.OpenConnection("production", True)
End If
If Not IsObject(session) Then
Set session = Connection.Children(0)
End If
session.findById("wnd[0]/usr/txtRSYST-MANDT").Text = "CLIENT"
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 = ""
session.findById("wnd[0]/usr/txtRSYST-LANGU").SetFocus
session.findById("wnd[0]/usr/txtRSYST-LANGU").caretPosition = 2
session.findById("wnd[0]").sendVKey 0
Set wshell = CreateObject("Wscript.Shell")
wshell.Run Chr(34) & Path & "\script.vbs" & Chr(34), 1, 1
End Sub
Anyone send me the Exact code related to this.................
Its very immediate requirement.................
Regards
Karthick
This message was moderated.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Karthick,
You could try the following:
Sub Test()
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 = "/nmm01"
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
SAP GUI should appear in the new design, you must do the following:
START -> All Programs -> SAP Front End -> SAP GUI Configuration -> Application -> Add -> excel.exe -> Open
If the program is started from a VBS file, it must be entered here wscript.exe.
Regards,
ScriptMan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ScriptMan,
I copied and pasted ur Coding, Now working with some Error,i Specfied below and I Don't have access to do Config and all
START -> All Programs -> SAP Front End -> SAP GUI Configuration -> Application -> Add -> excel.exe -> Open. If the program is started from a VBS file, it must be entered here wscript.exe.
Tht Option is disabled in my system, is there any other option is to do...
And when iam Runing ur code it displaying popup messages one by one.. Like this..
1. A Script is Opening a connection to SAPSytem
2.After then It Showing Error Message " Out of Memory", Thats it.. after No Output... how to rectify it...
3. Some times its opening SAP Login screen, Then we have to enter Manually...........
Is there Any method rectify it..........
Anyother option is there ScriptMan.. If possible send me code...........
Waiting For ur rply
Thanks & Regards
Karthick
Hi Karthick,
First of all I would do the following:
SAP GUI -> ALT / F12 (lokal layout tune) -> Options -> Scripting ->
Notify when a script connects to SAP GUI -> deactivate
Notify when a script establishes a connection -> deactivate
Then one would have to see what errors come else.
Regards,
ScriptMan
Very Thanks for Reply Scriptman.
I need another help from you.
Now, I'm using a code that you provided in a discussion.
The code opens a new SAP application and if we have an excisting session while running the macro it closes the excisting session and opens a new one. can you please help me to open a new session with the code without closing the excisting one.
Thanks
Ram
Hello Thomas or Anyone who can help,
I have had the similar issue as Praveen Meena,
while using my script to launch SAP through VBA macro in excel 2010.
After adding the excel.exe to sap gui applications it failed to log me in through vba.
As far as I know I should be able to connect to SAP with no logging credentials (with no manual keying), VBA script already includes those credentials
This would be the first step.
Secondly I woul dlike to connect to specific T-Code and set the parameters to create a data for analysis...
I would appreciate professional assistance
Jack
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.