on 09-08-2014 6:56 AM
Hello All,
I have one requriment, I have to login SAP system through Excell.
For login to MS Excell,is it requried to SAP LOGON pad should be insatalled in SYSTEM.
I am using Below code to login.
Sub logon_to_sap()
Set ObjR3 = CreateObject("SAP.Functions")
'--get this info from your logon pad..
ObjR3.Connection.System = "CRM" 'System name like : DEV 3 letter'
ObjR3.Connection.Client = "100" 'client number like 100'
ObjR3.Connection.User = "" 'User ID to logon '
ObjR3.Connection.Password = "" 'Password '
ObjR3.Connection.Language = "EN" 'Language'
ObjR3.Connection.ApplicationServer = "xx.xx.xx.xx 'Applicaiotn server name e.g. 10.x.x.x'
ObjR3.Connection.SystemNumber = "00" 'Instance number'
'--if no logon then exit\
If ObjR3.Connection.logon(0, False) <> True Then
WScript.Echo "Sap connection error - " & ObjR3.Connection.User & " - " & ObjR3.Connection.System
WScript.Quit
End If
End Sub
But I am getting below Error.
“Error Group
RFC_ERROR_COMMUNICATION
Message
CMALLC : rc=20 > Connect from SAP gateway to RFC
server failed
Connect_PM GWHOST='XX.XX.XX.XX , GWSERV=sapgw00,
SYSNR=00
LOCATION SAP-Gateway on host
ERROR partner
'XX.XX.XX.XX sapgw00' not reached
TIME Sep
10:21:50 2014
RELEASE 721
COMPONENT NI (network interface)
VERSION 40
RC
-10
MODULE nixxi.cpp
LINE 3286
DETAIL NiPConnect2:
SYSTEM CALL connect
ERRNO 10060
ERRNO TEXT WSAETIME
“
Thanks In advance.
Regards
RR Pradhan
Hello All,
I think I can use web service .
this is my VBA code
Private Sub CommandButton1_Click()
Dim sURL As String
Dim sEnv As String
Dim xmlhtp As New MSXML2.XMLHTTP40
Dim xmlDoc As New DOMDocument
sEnv = "<?xml version=""1.0"" encoding=""utf-8""?>"
sEnv = sEnv & "<soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">"
'sEnv = sEnv & "<soap:Envelope xmlns:xsi="""http://www.w3.org/2001/XMLSchema-instance"http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd="""http://www.w3.org/2001/XMLSchema"]http://www.w3.org/2001/XMLSchema[/URL]"" xmlns:soap=""[URL="http://schemas.xmlsoap.org/soap/envelope/"]http://schemas.xmlsoap.org/soap/envelope/"">"
sEnv = sEnv & " <soap:Body>"
sEnv = sEnv & " <sdef_ZWS_TEST_UDAY_WEB xmlns=""http://ides.studynest.org/webservices" > ""
sEnv = sEnv & " <DESC>Test Of Visit Reprot by Prasmi</DESC>"
sEnv = sEnv & " <PROCESS_TYPE>LEAD</PROCESS_TYPE>"
sEnv = sEnv & " </sdef_ZWS_TEST_UDAY_WEB>"
sEnv = sEnv & " </soap:Body>"
sEnv = sEnv & "</soap:Envelope>"
With xmlhtp
.Open "post", sURL, False
.setRequestHeader "Host", "ides.studynest.org"
.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
.setRequestHeader "soapAction", "http://ides.studynest.org:8023/sap/bc/srt/wsdl/sdef_ZWS_TEST_UDAY_WEB/wsdl11/ws_policy/document?sap-..."
.setRequestHeader "Accept-encoding", "zip"
.send (sEnv)
xmlDoc.LoadXML .responseText
MsgBox .responseText
End With
End Sub
this is my Webservice code
<?xml version="1.0" encoding="utf-8"
?>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Please go through below link for SAP GUI scripting
You can also use SAPSHCUT.EXE for logging in SAP system via EXCEL
fileLocation = Complete path of SAPSHCUT.exe file with file name"
Shell fileLocation " & " -sysname=" & "SID" & " -client=" & "100" & " -guiparam=" & "FQDN SYSNr." & " -user=" & "user_name" & " -pw=" & "password" & " -command" & "TCode" & " -max"
----------------------------- OR ----------------------------------
Paste the below code in notepad and save the file as login.vbs and run by double clicking it
dim sapgui
Set WshShell = WScript.CreateObject("WScript.Shell")
sapgui="sapshcut.exe" & " -sysname=" & "SID" & " -client=" & "100" & " -guiparam=" & "InstanceName SYSNr." & " -user=" & "user_name" & " -pw=" & "password" & " -command" & "TCode" & " -max"
wshShell.Run(sapgui)
Here -guiparam takes instance name and system number separated by space as arguement.
Hope this helps.
Regards,
Prithviraj.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello.
May you can check if
wscript.echo ObjR3.Connection.LastError will bring some more specific info.
For me it seems like that Scripting is not enabled on this System. Or RFC-communication is blocked.
Best regards
Holger
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.