functionCtrl = CreateObject("SAP.Functions") sapConnection = functionCtrl.Connection sapConnection.Client = "900" sapConnection.User = "RFC" sapConnection.Language = "DE" sapConnection.System = "PU1" sapConnection.ApplicationServer = "128.1.1.5" sapConnection.Password = "xyz" If sapConnection.Logon(0, .T.) <> .T. WAIT clear MESSAGEBOX("No Connection to R/3!",0.p_messagetitel) return EndIf * calling the sapfunction theFunc = functionCtrl.Add("Z_COFU_INNENAUF_RFC")Up to here everything works !!!!
Sub Auftraege() Dim iRow As Integer Dim functionCtrl As Object 'Function Control (Sammelobjekt) Dim sapConnection As Object 'Verbindungsobjekt Dim theFunc As Object 'Function Objekt Dim returnFunc As Boolean ' Rückgabewert des FB Dim meldungen As Object Dim i_auf As Object Dim aufdat Dim Filename As String Dim StrLineText As String Dim aufArray() As Variant Dim aufFelder Dim i As Integer Set functionCtrl = CreateObject("SAP.Functions") Set sapConnection = functionCtrl.Connection sapConnection.Client = "900" sapConnection.User = "RFC" sapConnection.Language = "DE" sapConnection.System = "PU1" sapConnection.ApplicationServer = "128.1.1.5" sapConnection.Password = "xyz" If sapConnection.Logon(0, True) <> True Then MsgBox "no connection to R/3!" Exit Sub End If Set theFunc = functionCtrl.Add("Z_COFU_INNENAUF_RFC") Set i_auf = theFunc.tables.Item("I_AUF") ' reading a text file with data ' this is the data i have in my foxprocursor mentioned above ' we create it with copy to type csv Filename = "u:\aufsapc.txt" aufdat = FreeFile() Open Filename For Input As #aufdat While Not EOF(aufdat) Line Input #aufdat, StrLineText ReDim Preserve aufArray(12, i) aufArray(0, i) = Mid(StrLineText, 1, 12) aufArray(1, i) = Mid(StrLineText, 13, 4) aufArray(2, i) = Mid(StrLineText, 17, 40) aufArray(3, i) = Mid(StrLineText, 57, 4) aufArray(4, i) = Mid(StrLineText, 61, 4) aufArray(5, i) = Mid(StrLineText, 65, 10) aufArray(6, i) = Mid(StrLineText, 75, 10) aufArray(7, i) = Mid(StrLineText, 85, 8) aufArray(8, i) = Mid(StrLineText, 93, 8) aufArray(9, i) = Mid(StrLineText, 101, 6) aufArray(10, i) = Mid(StrLineText, 107, 6) aufArray(11, i) = Mid(StrLineText, 113, 2) aufArray(12, i) = Mid(StrLineText, 115, 10) Set auftrag = i_auf.appendrow 'For Each auftrag In i_auf.Rows auftrag("AUFNR") = aufArray(0, i) auftrag("AUART") = aufArray(1, i) auftrag("KTEXT") = aufArray(2, i) auftrag("BUKRS") = aufArray(3, i) auftrag("GSBER") = aufArray(4, i) auftrag("PRCTR") = aufArray(5, i) auftrag("KOSTV") = aufArray(6, i) auftrag("USER7") = aufArray(7, i) auftrag("USER8") = aufArray(8, i) auftrag("KALSM") = aufArray(9, i) auftrag("PROGP") = aufArray(10, i) auftrag("AENKZ") = aufArray(11, i) auftrag("BRCHE") = aufArray(12, i) 'Next i = i + 1 Wend theFunc.Exports("L_AUF") = StrLineText ' theFunc.tables("I_AUF").Rows = aufArray() returnFunc = theFunc.Call exeptnFunc = theFunc.Exception If returnFunc = True Then Set ok = theFunc.imports("OK") If ok = "" Then Set meldungen = theFunc.imports("L_MSG") End If Set i_msg = theFunc.tables("I_MSG") Set i_mtab = theFunc.tables("I_MTAB") Else MsgBox theFunc.Exception End If functionCtrl.Connection.Logoff Set sapConnection = Nothing Set functionCtrl = Nothing MsgBox "Finished!", vbInformation, "End" End SubAny help welcomed