0

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).

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
  • Could you describe the exact symptom please, and at what line does it happen? – Sandra Rossi Oct 08 '20 at 05:17
  • If you have an open sap.function connection object (myConnection) and place that in the VBA watch window, you will find that as soon as you set the myConnection.connection.password = "mypassword" the myConnection.connection object is trashed. This is under SAPGUI 7.6 pl4. – Crew Reynolds Oct 09 '20 at 14:06
  • I had this issue and thought that it was solved by using `SAP.Functions` instead of `SAP.LogonControl`. Anyway, could you try by removing the `.Unicode` part, just in case? If it doesn't work, and if you use a 64 bits version of Office, could you try to delegate the 32 bits version of SAP.Functions(.Unicode) to 64 bits by editing the Windows registry as explained [here](https://answers.sap.com/comments/13152790/view.html)? – Sandra Rossi Oct 09 '20 at 20:07
  • We have been using SAP.FUNCTIONS and SAP.FUNCTIONS.UNICODE equally well for some time now. Things changed from SAPGUI 7.40 -> 7.50. SAPGUI 7.50's connection layer was built on NWRFC which, for a long time, was not working with message servers (until 7.50 pl9). We are connection to SAP with 7.60 pl6 using the MYSAPSSO ticket (portal SSO). The ticket is not this issue. It is in how the parameters must be filled out for the message server since NWRFC came into the picture. – Crew Reynolds Oct 13 '20 at 16:46
  • You didn't say if you have a 64bits Office version and if you tried to define [DLLSurrogate](https://answers.sap.com/comments/13152790/view.html) in the Windows registry. Just to see. I can successfully connect silently with your code in SAPGUI 7.6 pl1 (without SSO). – Sandra Rossi Oct 13 '20 at 17:14

1 Answers1

0

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 (a.k.a. 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.