Code: Alles auswählen.
' Kontraktart
Call FillInterface(theFunc, Sammler, "SALES_HEADER_IN", i)
' Auftraggeber
Call FillInterface(theFunc, Auftraggeber, "SALES_PARTNERS", i)
'Positionen
Call FillInterface(theFunc, Pos, "SALES_ITEMS_IN", i)
'End If
' Aufruf der BAPI-Funktion und Auswerten aufgetretener Fehler
iStartPos = 11
Call BAPIFunction(theFunc, i, iStartPos)
Code: Alles auswählen.
Sub BAPIFunction(ByRef theFunc As Object, iRow As Integer, iStartPos As Integer)
Dim RetTable As Object
Dim sMessage As String
Dim sTypeMsg As String
returnFunc = False
'Aufruf des Bapi
returnFunc = theFunc.Call
...
Code: Alles auswählen.
Sub FillInterface(ByRef theFunc As Object, ByRef ObjectName As Object, sParamName As String, iRow As Integer)
Select Case sParamName
Case "SALES_HEADER_IN"
Set ObjectName = theFunc.exports(sParamName)
ObjectName.Value("DOC_TYPE") = Cells(iRow, 1)
ObjectName.Value("SALES_ORG") = Cells(iRow, 2)
ObjectName.Value("DISTR_CHAN") = Cells(iRow, 3)
ObjectName.Value("DIVISION") = Cells(iRow, 4)
ObjectName.Value("DATE_TYPE") = Cells(iRow, 5)
Case "SALES_PARTNERS"
Set ObjectName = theFunc.tables.Item(sParamName)
ObjectName.AppendRow
For Each ObjectName In ObjectName.Rows
ObjectName("PARTN_ROLE") = Cells(iRow, 6)
ObjectName("PARTN_NUMB") = Cells(iRow, 7)
Next
Case "SALES_ITEMS_IN"
Set ObjectName = theFunc.tables.Item(sParamName)
ObjectName.AppendRow
For Each ObjectName In ObjectName.Rows
ObjectName("MATERIAL") = Cells(iRow, 8)
ObjectName("TARGET_QTY") = Cells(iRow, 9)
Next
Case "DEFAULTS"
Set ObjectName = theFunc.exports(sParamName)
MsgBox sParamName
End Select
End Sub
Code: Alles auswählen.
returnFunc = theFunc.Call