Skip to Content
avatar image
Former Member

LOGIN TO SAP SYSTEM from Ms Excell

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

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • Sep 08, 2014 at 10:04 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Holger,

      Thanks for your reply.

      Please help me,How to enable the scriptng system and RFC comunication.

      Regards

      RR PRADHAN

  • avatar image
    Former Member
    Sep 10, 2014 at 12:05 PM

    Hi,

    Please go through below link for SAP GUI scripting

    Introduction to 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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 10, 2014 at 07:34 PM

    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

    'sURL = "http://webservices.gama-system.com/exchangerates.asmx?op=CurrentConvertToEUR"]http://webservices.gama-system.com/exchangerates.asmx?op=CurrentConvertToEUR[/URL]"

    sURL = "http://ides.studynest.org:8023/sap/bc/srt/wsdl/sdef_ZWS_TEST_UDAY_WEB/wsdl11/ws_policy/document?sap-client=800"

    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-client=800"

    .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"
    ?>


    - < wsdl:definitions
    targetNamespace =" urn:sap-com:document:sap:soap:functions:mc-style " xmlns:wsdl =" http://schemas.xmlsoap.org/wsdl/ " xmlns:xsd =" http://www.w3.org/2001/XMLSchema " xmlns:soap =" http://schemas.xmlsoap.org/wsdl/soap/ " xmlns:wsoap12 =" http://schemas.xmlsoap.org/wsdl/soap12/ " xmlns:http =" http://schemas.xmlsoap.org/wsdl/http/ " xmlns:mime =" http://schemas.xmlsoap.org/wsdl/mime/ " xmlns:tns =" urn:sap-com:document:sap:soap:functions:mc-style " xmlns:wsp =" http://schemas.xmlsoap.org/ws/2004/09/policy " xmlns:wsu =" http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd " xmlns:n1 =" urn:sap-com:document:sap:rfc:functions " >


    - < wsdl:documentation >


    < sidl:sidl xmlns:sidl =" http://www.sap.com/2007/03/sidl "
    />
    </ wsdl:documentation >

    < wsp:UsingPolicy wsdl:required =" true " />

    - < wsp:Policy
    wsu:Id =" IF_IF_zws_test_uday_web " >


    - < sapsession:Session
    xmlns:sapsession =" http://www.sap.com/webas/630/soap/features/session/ " >


    < sapsession:enableSession > false </ sapsession:enableSession >
    </ sapsession:Session >
    </ wsp:Policy >

    - < wsp:Policy
    wsu:Id =" OP_IF_OP_ZcrmOrderMaintainUday " >


    < sapblock:enableBlocking
    xmlns:sapblock =" http://www.sap.com/NW05/soap/features/blocking/ " > true </ sapblock:enableBlocking >

    < sapcomhnd:enableCommit
    xmlns:sapcomhnd =" http://www.sap.com/NW05/soap/features/commit/ " > false </ sapcomhnd:enableCommit >

    < saptrhnw05:required
    xmlns:saptrhnw05 =" http://www.sap.com/NW05/soap/features/transaction/ " > no </ saptrhnw05:required >

    < saprmnw05:enableWSRM
    xmlns:saprmnw05 =" http://www.sap.com/NW05/soap/features/wsrm/ " > false </ saprmnw05:enableWSRM >
    </ wsp:Policy >

    - < wsdl:types >


    - < xsd:schema
    attributeFormDefault =" qualified " targetNamespace =" urn:sap-com:document:sap:rfc:functions " >


    - < xsd:simpleType
    name =" char10 " >


    - < xsd:restriction
    base =" xsd:string " >


    < xsd:maxLength value =" 10 " />
    </ xsd:restriction >
    </ xsd:simpleType >

    - < xsd:simpleType
    name =" char255 " >


    - < xsd:restriction
    base =" xsd:string " >


    < xsd:maxLength value =" 255 " />
    </ xsd:restriction >
    </ xsd:simpleType >

    - < xsd:simpleType
    name =" char3 " >


    - < xsd:restriction
    base =" xsd:string " >


    < xsd:maxLength value =" 3 " />
    </ xsd:restriction >
    </ xsd:simpleType >

    - < xsd:simpleType
    name =" char32 " >


    - < xsd:restriction
    base =" xsd:string " >


    < xsd:maxLength value =" 32 " />
    </ xsd:restriction >
    </ xsd:simpleType >

    - < xsd:simpleType
    name =" char4 " >


    - < xsd:restriction
    base =" xsd:string " >


    < xsd:maxLength value =" 4 " />
    </ xsd:restriction >
    </ xsd:simpleType >

    - < xsd:simpleType
    name =" char40 " >


    - < xsd:restriction
    base =" xsd:string " >


    < xsd:maxLength value =" 40 " />
    </ xsd:restriction >
    </ xsd:simpleType >

    - < xsd:simpleType
    name =" date " >


    - < xsd:restriction
    base =" xsd:string " >


    < xsd:maxLength value =" 10 " />

    < xsd:pattern value =" \d\d\d\d-\d\d-\d\d " />
    </ xsd:restriction >
    </ xsd:simpleType >

    - < xsd:simpleType
    name =" decimal28.9 " >


    - < xsd:restriction
    base =" xsd:decimal " >


    < xsd:totalDigits value =" 28 " />

    < xsd:fractionDigits value =" 9 " />
    </ xsd:restriction >
    </ xsd:simpleType >

    - < xsd:simpleType
    name =" numeric3 " >


    - < xsd:restriction
    base =" xsd:string " >


    < xsd:maxLength value =" 3 " />

    < xsd:pattern value =" \d* " />
    </ xsd:restriction >
    </ xsd:simpleType >
    </ xsd:schema >

    - < xsd:schema
    attributeFormDefault =" qualified " targetNamespace =" urn:sap-com:document:sap:soap:functions:mc-style " xmlns:n0 =" urn:sap-com:document:sap:rfc:functions " >


    < xsd:import namespace =" urn:sap-com:document:sap:rfc:functions " />

    - < xsd:element
    name =" ZcrmOrderMaintainUday " >


    - < xsd:complexType >


    - < xsd:sequence >


    < xsd:element name =" Client " type =" n0:char32 "
    minOccurs =" 0 " />

    < xsd:element name =" CloseDate " type =" n0:date "
    minOccurs =" 0 " />

    < xsd:element name =" Desc " type =" n0:char40 " />

    < xsd:element name =" ExpRevenue " type =" n0:decimal28.9 "
    minOccurs =" 0 " />

    < xsd:element name =" Phase " type =" n0:char3 "
    minOccurs =" 0 " />

    < xsd:element name =" ProcessType " type =" n0:char4 "
    />

    < xsd:element name =" Salesemp " type =" n0:char32 "
    minOccurs =" 0 " />

    < xsd:element name =" StartDate " type =" n0:date "
    minOccurs =" 0 " />

    < xsd:element name =" Success " type =" n0:numeric3 "
    minOccurs =" 0 " />
    </ xsd:sequence >
    </ xsd:complexType >
    </ xsd:element >

    - < xsd:element
    name =" ZcrmOrderMaintainUdayResponse " >


    - < xsd:complexType >


    - < xsd:sequence >


    < xsd:element name =" Message " type =" n0:char255 "
    />

    < xsd:element name =" ObjectId " type =" n0:char10 "
    />
    </ xsd:sequence >
    </ xsd:complexType >
    </ xsd:element >
    </ xsd:schema >
    </ wsdl:types >

    - < wsdl:message
    name =" ZcrmOrderMaintainUday " >


    < wsdl:part name =" parameters "
    element =" tns:ZcrmOrderMaintainUday " />
    </ wsdl:message >

    - < wsdl:message
    name =" ZcrmOrderMaintainUdayResponse " >


    < wsdl:part name =" parameter "
    element =" tns:ZcrmOrderMaintainUdayResponse " />
    </ wsdl:message >

    - < wsdl:portType
    name =" zws_test_uday_web " >


    - < wsdl:documentation >


    - < sapdoc:sapdoc
    xmlns:sapdoc =" urn:sap:esi:documentation " >


    < sapdoc:docitem docURL =" http://ides.studynest.org:8023/sap/bc/esdt/docu/sd_text?sap-client=800&sd_name=ZWS_TEST_UDAY_WEB " />
    </ sapdoc:sapdoc >
    </ wsdl:documentation >

    - < wsp:Policy >


    < wsp:PolicyReference URI =" #IF_IF_zws_test_uday_web " />
    </ wsp:Policy >

    - < wsdl:operation
    name =" ZcrmOrderMaintainUday " >


    - < wsp:Policy >


    < wsp:PolicyReference URI =" #OP_IF_OP_ZcrmOrderMaintainUday " />
    </ wsp:Policy >

    < wsdl:input message =" tns:ZcrmOrderMaintainUday " />

    < wsdl:output message =" tns:ZcrmOrderMaintainUdayResponse " />
    </ wsdl:operation >
    </ wsdl:portType >
    </ wsdl:definitions > BUT I am getting Attached Error.

    Untitled.png (135.0 kB)
    Add comment
    10|10000 characters needed characters exceeded