Code: Alles auswählen.
Set sapConnection = functionCtrl.Connection
sapConnection.Client = "000"
sapConnection.user = "SAPuser"
sapConnection.Language = "DE"
If sapConnection.logon(0, False) <> True Then
MsgBox "Keine Verbindung zum R/3!"
Exit Sub 'Programm beenden
End If
Set theFunc = functionCtrl.Add("RFC_CUSTOMER_GET")
Worksheets(1).Select
Cells.Clear
Dim customers As Object
Dim returnFunc As Boolean
Dim startzeil As Integer
Dim endcol As Integer
Dim the_name As String
startzeil = 1
For start_char = Asc("A") To Asc("Z")
the_name = Chr$(start_char) + "*"
theFunc.exports("NAME1") = the_name
theFunc.exports("KUNNR") = "*"
returnFunc = theFunc.Call
die_exception = theFunc.Exception
If returnFunc = True Then
Set customers = theFunc.tables.Item("CUSTOMER_T")
endcol = 0
Call display_customers (the_name, customers, startzeil, endcol)
startzeil = endcol
Set customers = Nothing
Else
If die_exception = "NO_RECORD_FOUND" Then
Cells(startzeil, 1) = "Keine Werte vorhanden für " + the_name
startzeil = startzeil + 1
Else
MsgBox "Fehler beim Zugriff auf Funktion im R/3 ! "
Exit Sub
End If
End If
Next start_char
...
Sub display_customers(aName As String, ByRef customers_table As Object, start_zeil As Integer, ByRef end_col As Integer)
Cells(start_zeil, 1) = "KundenNr."
Cells(start_zeil, 2) = "Anrede "
Cells(start_zeil, 3) = "Kundenname " + aName
Cells(start_zeil, 4) = "PLZ"
Cells(start_zeil, 5) = "Ort"
Cells(start_zeil, 6) = "Tel.Nr "
Range(Cells(start_zeil, 1), Cells(start_zeil, 6)).Font.Bold = True
bManyCustomers = False
If (bManyCustomers = False) Then
i = start_zeil + 2
For Each Customer In customers_table.Rows
Cells(i, 1) = Trim(Customer("KUNNR"))
Cells(i, 2) = Customer("ANRED")
Cells(i, 3) = Customer("NAME1")
Cells(i, 4) = Customer("PSTLZ")
Cells(i, 5) = Customer("ORT01")
Cells(i, 6) = Customer("TELF1")
i = i + 1
Next
End If
end_col = i
End Sub
functionCtrl.Connection.logoff
Set sapConnection = Nothing
Set functionCtrl = Nothing
MsgBox "Programm beendet!", 16, "Beenden"