My code ends with the MsgBox "TECO FuBa Call false!"
.
The LogOn
and Logout
functions are working fine, and when I test the function module BAPI_ALM_ORDER_MAINTAIN
via SAP GUI transaction code SE37
, everything works fine.
I have already checked: PM Order change status to TECO
Public Sub teco()
Dim auftr As String
Dim teco_date As Date
teco_date = Format(Now, "dd/MM/yyyy")
auftr = "000123456789"
Dim oFuBa As Object
Set oFuBa = Nothing
Set oFuBa = objBAPIControl.Add("BAPI_ALM_ORDER_MAINTAIN")
' EXPORTING
Dim e_import As Variant
Set e_import = oFuBa.Exports("IV_MMSRV_EXTERNAL_MAINTENACE")
e_import.Value = ""
' TABLES
Dim t_methods_data As Variant
Set t_methods_data = oFuBa.Tables("IT_METHODS")
Dim Row As Object
Set Row = t_methods_data.Rows.Add
Row("REFNUMBER") = "0001"
Row("OBJECTTYPE") = "HEADER"
Row("METHOD") = "TECHNICALCOMPLETE"
Row("OBJECTKEY") = auftr
Set Row = t_methods_data.Rows.Add
Row("REFNUMBER") = "0001"
Row("OBJECTTYPE") = ""
Row("METHOD") = "SAVE"
Row("OBJECTKEY") = auftr
MsgBox CStr(t_methods_data.RowCount)
Dim t_header_data As Variant
Set t_header_data = oFuBa.Tables("IT_HEADER")
Set Row = t_header_data.Rows.Add
Row("ORDERID") = auftr
Row("TECO_REF_DATE") = CStr(teco_date)
Row("TECO_REF_TIME") = "00:00:00"
MsgBox CStr(t_header_data.RowCount)
Dim t_return As Variant
Set t_return = oFuBa.Tables("RETURN")
If oFuBa.Call = True Then
If t_return.RowCount > 0 Then
If t_return.Cell(1, 1) = "E" Then
Dim oFuBa2 As Object
Set oFuBa2 = objBAPIControl.Add("BAPI_TRANSACTION_ROLLBACK")
If oFuBa2.Call = True Then
t_methods_data.Rows.Remove
t_methods_data.Rows.Remove
t_header_data.Rows.Remove
End If
Else
Dim oFuBa3 As Object
Set oFuBa3 = objBAPIControl.Add("BAPI_TRANSACTION_COMMIT")
If oFuBa3.Call = True Then
MsgBox "TECO commit true!"
Else
MsgBox "TECO commit false!"
End If
End If
MsgBox "Ende Teco!"
Else
MsgBox "Ende TECO return False!"
End If
Else
If oFuBa.Exception <> "" Then
MsgBox "Exception: " & oFuBa.Exception
End If
MsgBox "TECO FuBa Call false!"
End If
End Sub
What am I doing wrong?