Skip to Content
author's profile photo Former Member
Former Member

Logon from VBA to R3

I have following code to connect from VBA to R3

If I use SilentLogon = True, It will be fail.

If I use SilentLogon = False, logon screen will popup, directly click logon will be fail too.

If I use SilentLogon = False, logon screen will popup and I select the existing system that I have, fill all the same information in this code and logon, the connection run successfully.

In this situation where I'm wrong ?

Can I debug to see which parameter I typed wrong ?

Thank you.

Halomoan

Sub connectR3()

Set LogonControl = CreateObject("SAP.LogonControl.1")
Set R3Connection = LogonControl.NewConnection
R3Connection.Client = "130"
R3Connection.ApplicationServer = "10.10.6.10"
R3Connection.Language = "EN"
R3Connection.User = "user1"
R3Connection.Password = "tiger"
R3Connection.System = "00"

SilentLogon = True


retcd = R3Connection.Logon(0, SilentLogon)
If retcd <> True Then
   MsgBox "Logon Failed"
else
  Msgbox "Logon Success"
  R3Connection.Logoff
End if
End Sub

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Oct 24, 2008 at 10:30 AM

    too much to think about, just use this:

    Set FunctionCtrl = CreateObject("SAP.Functions")

    Set SapConnection = FunctionCtrl.Connection

    SapConnection.client = "<Client>"

    SapConnection.user = "<logon user>"

    SapConnection.password = "<Logon Password>"

    SapConnection.language = "EN"

    SapConnection.HostName = "<hostanme>"

    SapConnection.SystemNumber = "<SySnr>"

    If Not SapConnection.Logon(0, True) Then

    msgbox ("not Connected")

    else

    msgbox ("connected")

    End If

    SapConnection.logoff

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.