Code: Alles auswählen.
Option Explicit
Public functionCtrl As Object 'Function Control (Sammelobjekt: Container)
Public sapConnection As Object 'Verbindungsobjekt
Public theFunc As Object 'Function Objekt
Public die_exception As Variant
Public returnFunc As Boolean
Sub Testauftrag()
'Erstellen eines Funktionsobjektes
Set functionCtrl = CreateObject("SAP.Functions")
Set sapConnection = functionCtrl.Connection
'Logon mit Initialwerten
sapConnection.Client = "005"
sapConnection.user = "mein User"
sapConnection.Language = "DE"
If sapConnection.Logon(0, False) <> True Then
MsgBox "Keine Verbindung zum R/3!", vbCritical
Call Finish(functionCtrl, sapConnection)
Exit Sub 'Programm beenden
End If
'Referenz auf Funktionsobjekt "Z_AS_TEST_VA21"
Set theFunc = functionCtrl.Add("Z_AS_TEST_VA21")
returnFunc = False
theFunc.Exports("I_AUART") = "AG"
returnFunc = theFunc.Call
die_exception = theFunc.exception
End Sub