简体   繁体   中英

Why can't I create a silent SAP RFC connection

I would like to create a silent SAP.FUNCTIONS connection to SAP using Excel VBA. Whenever I set the password, the connection object gets trashed. Is this even possible?

Sub Connect_to_SAP()

    Dim myConnection As Object
    Set myConnection = CreateObject("SAP.Functions.unicode")
    
    With myConnection
      .Connection.System = "SID" 'Systemname
      .Connection.client = "800" 'Client
      .Connection.APPLICATIONSERVER = "192.111.222.333"
      .Connection.user = "MYUSERNAME" 'User
      .Connection.Password = "MYPASSWORD" ' <=== after that, myConnection.connection object is trashed
      .Connection.Language = "EN" 'Language
      .Connection.systemnumber = "00" 'Systemnumber
    End With
    
    'Establish connection.
    If myConnection.Connection.logon(0, True) <> True Then Exit Sub
    'System Logoff
    myConnection.Connection.LOGOFF

End Sub

NB: This is under SAPGUI 7.6 pl4. We are connecting to SAP with 7.60 pl6 using the MYSAPSSO ticket (portal SSO).

In order to test that a silent connection is working under 7.60 pl4, here were my steps.

  1. Use the standard SAP login dialog (aka loud) and make a connection. .Logon(0, False)
  2. Create a new connection object and set it = to the open connection.
  3. Log out of the first (loud connection) and set it to nothing.
  4. With the new connection filled in (including the encrypted password from the loud login) I can then just exec.Logon(0, True) to test a silent logon.

This works fine. It still doesn't give me any way to convert a user's password string to an SAP required encrypted password directly. Still, this does prove that a silent login does work under 7.50+ which was my original goal.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM