我正在使用SAP功能“BAPI_ALM_ORDERHEAD_GET_LIST”来检索订单号12345.我想通过将日期移至2015年1月1日来更改日期。我找不到有关如何更改我通过SAP引入的字段的文档RFC。我可以通过代码从SAP获得订单,但我不知道如何更改日期。这是我的代码:
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?
答案 0 :(得分:0)
据我所知,您需要使用BAPI BAPI_ALM_ORDER_MAINTAIN
。请务必查阅该功能模块的文档。
答案 1 :(得分:0)
如果有人需要,这是答案。
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