我的要求是更改销售订单项目详细信息。
为此,我使用BAPI_SALESOPDER_CHANGE
。
- 对于一行项目,它工作良好。
- 包含两行项目的销售订单,对于第10行项目其更新数量,但对于第20行项目它以随机值更新。
- SO包含三个项目显示异常
我的代码在这里:
DATA: SALESDOCUMENT TYPE BAPIVBELN-VBELN.
DATA: LT_ORDER_HEADER_INX TYPE TABLE OF BAPISDH1X,
LS_ORDER_HEADER_INX TYPE BAPISDH1X.
DATA: LT_ORDER_ITEM_IN TYPE TABLE OF BAPISDITM,
LS_ORDER_ITEM_IN TYPE BAPISDITM.
DATA: LT_ORDER_ITEM_INX TYPE TABLE OF BAPISDITMX,
LS_ORDER_ITEM_INX TYPE BAPISDITMX.
DATA: LT_SCHEDULE_LINES TYPE TABLE OF BAPISCHDL,
LS_SCHEDULE_LINES TYPE BAPISCHDL.
DATA: LT_SCHEDULE_LINESX TYPE TABLE OF BAPISCHDLX,
LS_SCHEDULE_LINESX TYPE BAPISCHDLX.
DATA: LT_RETURN TYPE TABLE OF BAPIRET2,
LS_RETURN TYPE BAPIRET2.
PARAMETERS: p_sonum TYPE BAPIVBELN-VBELN.
LS_ORDER_HEADER_INX-UPDATEFLAG = 'U'.
LS_ORDER_ITEM_IN-ITM_NUMBER = 10.
LS_ORDER_ITEM_IN-TARGET_QTY = 22.
APPEND LS_ORDER_ITEM_IN TO LT_ORDER_ITEM_IN.
clear: LS_ORDER_ITEM_IN.
LS_ORDER_ITEM_IN-ITM_NUMBER = 20.
LS_ORDER_ITEM_IN-TARGET_QTY = 33.
APPEND LS_ORDER_ITEM_IN TO LT_ORDER_ITEM_IN.
clear: LS_ORDER_ITEM_IN.
LS_ORDER_ITEM_IN-ITM_NUMBER = 30.
LS_ORDER_ITEM_IN-TARGET_QTY = 44.
APPEND LS_ORDER_ITEM_IN TO LT_ORDER_ITEM_IN.
clear: LS_ORDER_ITEM_IN.
LS_ORDER_ITEM_INX-ITM_NUMBER = 10.
LS_ORDER_ITEM_INX-UPDATEFLAG = 'U'.
LS_ORDER_ITEM_INX-TARGET_QTY = 'X'.
APPEND LS_ORDER_ITEM_INX TO LT_ORDER_ITEM_INX.
clear:LS_ORDER_ITEM_INX.
LS_ORDER_ITEM_INX-ITM_NUMBER = 20.
LS_ORDER_ITEM_INX-UPDATEFLAG = 'U'.
LS_ORDER_ITEM_INX-TARGET_QTY = 'X'.
APPEND LS_ORDER_ITEM_INX TO LT_ORDER_ITEM_INX.
clear:LS_ORDER_ITEM_INX.
LS_ORDER_ITEM_INX-ITM_NUMBER = 30.
LS_ORDER_ITEM_INX-UPDATEFLAG = 'U'.
LS_ORDER_ITEM_INX-TARGET_QTY = 'X'.
APPEND LS_ORDER_ITEM_INX TO LT_ORDER_ITEM_INX.
clear:LS_ORDER_ITEM_INX.
LS_SCHEDULE_LINES-ITM_NUMBER = 10.
LS_SCHEDULE_LINES-SCHED_LINE = 1.
LS_SCHEDULE_LINES-REQ_QTY = 22.
APPEND LS_SCHEDULE_LINES TO LT_SCHEDULE_LINES.
clear:LS_SCHEDULE_LINES.
LS_SCHEDULE_LINES-ITM_NUMBER = 20.
LS_SCHEDULE_LINES-SCHED_LINE = 2.
LS_SCHEDULE_LINES-REQ_QTY = 33.
APPEND LS_SCHEDULE_LINES TO LT_SCHEDULE_LINES.
clear:LS_SCHEDULE_LINES.
LS_SCHEDULE_LINES-ITM_NUMBER = 30.
LS_SCHEDULE_LINES-SCHED_LINE = 3.
LS_SCHEDULE_LINES-REQ_QTY = 44.
APPEND LS_SCHEDULE_LINES TO LT_SCHEDULE_LINES.
clear:LS_SCHEDULE_LINES.
LS_SCHEDULE_LINESX-ITM_NUMBER = 10.
LS_SCHEDULE_LINESX-SCHED_LINE = 1.
LS_SCHEDULE_LINESX-UPDATEFLAG = 'U'.
LS_SCHEDULE_LINESX-REQ_QTY = 'X'.
APPEND LS_SCHEDULE_LINESX TO LT_SCHEDULE_LINESX.
CLEAR: LS_SCHEDULE_LINESX.
LS_SCHEDULE_LINESX-ITM_NUMBER = 20.
LS_SCHEDULE_LINESX-SCHED_LINE = 2.
LS_SCHEDULE_LINESX-UPDATEFLAG = 'U'.
LS_SCHEDULE_LINESX-REQ_QTY = 'X'.
APPEND LS_SCHEDULE_LINESX TO LT_SCHEDULE_LINESX.
CLEAR: LS_SCHEDULE_LINESX.
LS_SCHEDULE_LINESX-ITM_NUMBER = 30.
LS_SCHEDULE_LINESX-SCHED_LINE = 3.
LS_SCHEDULE_LINESX-UPDATEFLAG = 'U'.
LS_SCHEDULE_LINESX-REQ_QTY = 'X'.
APPEND LS_SCHEDULE_LINESX TO LT_SCHEDULE_LINESX.
CLEAR: LS_SCHEDULE_LINESX.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = p_sonum
order_header_inx = LS_ORDER_HEADER_INX
TABLES
return = LT_RETURN
ORDER_ITEM_IN = LT_ORDER_ITEM_IN
ORDER_ITEM_INX = LT_ORDER_ITEM_INX
SCHEDULE_LINES = LT_SCHEDULE_LINES
SCHEDULE_LINESX = LT_SCHEDULE_LINESX .
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
请确保您传递给BAPI的行项号前导为零。
除了添加前导零之外,我认为行项编号是1,2,3而不是10,20,30尝试以单个数字增量运行代码。也张贴lt_return
的结果,如果它不工作。
计划行与订单行绑定,因此它们应该开始为每个订单项重新编号。
在你的例子中,所有像
这样的行LS_SCHEDULE_LINES-SCHED_LINE = ???.
和
LS_SCHEDULE_LINESX-SCHED_LINE = ???.
应该LS_SCHEDULE_LINES-SCHED_LINE = 1.
和
LS_SCHEDULE_LINESX-SCHED_LINE = 1.