问题
I am using SAP function "BAPI_ALM_ORDERHEAD_GET_LIST" to retrieve order number 12345. I would like to change the date by moving it to January 01 2015. I can't find the documentation on how to change a field I pulled in with SAP RFC. I can get the order from SAP with the code but I dont know how to change the date. Here is my code:
objRfcFunc = doLogin()
With objRfcFunc.Tables("IT_RANGES")
Dim arrStr(,) As String = {{"OPTIONS_FOR_ORDERID", "12345"}, _
{"SHOW_OPEN_DOCUMENTS", "X"}, _
{"SHOW_DOCUMENTS_IN_PROCESS", "X"}, _
{"SHOW_COMPLETED_DOCUMENTS", "X"}, _
{"SHOW_HISTORICAL_DOCUMENTS", "X"}, _
{"SHOW_DOCS_WITH_FROM_DATE", "00010101"}, _
{"SHOW_DOCS_WITH_TO_DATE", "99991231"}}
For i = 0 To (arrStr.Length / arrStr.Rank) - 1
If .RowCount < i + 1 Then .Rows.Add()
.cell(i + 1, 1) = arrStr(i, 0)
.cell(i + 1, 2) = "I"
.cell(i + 1, 3) = "EQ"
.cell(i + 1, 4) = arrStr(i, 1)
Next
End With
If objRfcFunc.Call = False Then
MsgBox("Error occured - " & objRfcFunc.Exception)
Exit Sub
End If
'How do I change date here?
回答1:
As far as I can see, you need to use the BAPI BAPI_ALM_ORDER_MAINTAIN for this. Be sure to consult the documentation of that function module.
回答2:
Here is the awnser if anyone needed it.
objRfcFunc = sapFunc.Add("BAPI_ALM_ORDER_MAINTAIN")
With objRfcFunc.Tables("IT_METHODS")
If .RowCount < 1 Then .Rows.Add()
.cell(1, 1) = 1
.cell(1, 2) = "HEADER"
.cell(1, 3) = "CHANGE"
.cell(1, 4) = oNum
If .RowCount < 2 Then .Rows.Add()
.cell(2, 2) = ""
.cell(2, 3) = "SAVE"
End With
With objRfcFunc.Tables("IT_HEADER")
If .RowCount < 1 Then .Rows.Add()
.cell(1, "ORDERID") = oNum
.cell(1, "START_DATE") = "2016-11-03"
.cell(1, "BASICSTART") = "1:00 AM"
End With
With objRfcFunc.Tables("IT_HEADER_UP")
If .RowCount < 1 Then .Rows.Add()
.cell(1, "START_DATE") = "X"
.cell(1, "BASICSTART") = "X"
End With
If objRfcFunc.Call = False Then
MsgBox("Error occured - " & objRfcFunc.Exception)
Exit Sub
End If
Dim cmt = sapFunc.Add("BAPI_TRANSACTION_COMMIT")
If cmt.Call = False Then
MsgBox("Error occured Commiting - " & objRfcFunc.Exception)
Exit Sub
End If
cmt.exports("wait").value = "X"
tab = objRfcFunc.Tables("RETURN")
For i = 1 To tab.RowCount
If (tab.Cell(i, "TYPE") = "W" Or tab.Cell(i, "TYPE") = "E") Then
Console.WriteLine("<<-- <" & tab.Cell(i, "TYPE") & ">" & tab.Cell(i, "MESSAGE"))
End If
Next
来源:https://stackoverflow.com/questions/24014747/sap-rfc-how-to-change-date-on-a-pm-order