Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Sub Connection_SAP()
- Dim oFunc As SAPFunctionsOCX.SAPFunctions
- Dim oConn As SAPLogonCtrl.Connection
- Dim SAPConn As Integer
- Set oFunc = CreateObject("SAP.Functions.Unicode")
- If Not IsObject(oFunc) Then
- MsgBox "CreateObject(SAP.Functions.Unicode) failed", vbOKOnly, _
- "Error"
- Exit Sub
- End If
- Set oConn = oFunc.Connection()
- If Not IsObject(oConn) Then
- MsgBox "SAPFunc.Connection failed", vbOKOnly, "Error"
- Exit Sub
- End If
- oConn.Client = "100"
- oConn.User = "username"
- oConn.Password = "password"
- oConn.System = "prod02" ' db data - Name?
- oConn.Language = "EN"
- oConn.HostName = "sap01" ' db host or host data Server Name?
- SAPConn = oConn.Logon(0, vbFalse)
- If SAPConn <> 0 Then
- oConn.Logoff
- Else
- MsgBox "Connection.Logon failed", vbOKOnly, "Error"
- End If
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement