这里是修改采购订单BAPI,修改订单数量和交货日期的简单应用
文章目录
- 修改数量
- 代码
- 运行结果
- 修改交货日期
- 代码
- 运行结果
修改数量
代码
*&---------------------------------------------------------------------*
*& Report Z_BAPI_PO_CHANGE
*&---------------------------------------------------------------------*
*& Creator:LiuHongyu
*& Create On:2024.12.24 17:04:09
*& Type:
*& Description:采购订单修改BAPI调用-BAPI_PO_CHANGE
*&---------------------------------------------------------------------*
* Changed History
*-------------- --------------- ------------------ --------------*
* Version Changed By Changed Date Description
*-------------- --------------- ------------------ --------------*
* N LiuHongyu 24.12.2024 17:04:09
*&---------------------------------------------------------------------*REPORT Z_BAPI_PO_CHANGE.DATA PURCHASEORDER TYPE BAPIMEPOHEADER-PO_NUMBER.
DATA POITEM TYPE STANDARD TABLE OF BAPIMEPOITEM.
DATA POITEMX TYPE STANDARD TABLE OF BAPIMEPOITEMX.
DATA RETURN TYPE STANDARD TABLE OF BAPIRET2.
DATA LS_POITEM TYPE BAPIMEPOITEM.
DATA LS_POITEMX TYPE BAPIMEPOITEMX.PURCHASEORDER = '4500005963'. "采购订单BAPILS_POITEM-PO_ITEM = '00010'.
LS_POITEM-QUANTITY = 10.
APPEND LS_POITEM TO POITEM.LS_POITEMX-PO_ITEM = '00010'.
LS_POITEMX-QUANTITY = 'X'.
APPEND LS_POITEMX TO POITEMX.CALL FUNCTION 'BAPI_PO_CHANGE'EXPORTINGPURCHASEORDER = PURCHASEORDERTABLESRETURN = RETURNPOITEM = POITEMPOITEMX = POITEMX.LOOP AT RETURN INTO DATA(LS_RETURN) WHERE TYPE = 'E' OR TYPE = 'A'.WRITE:LS_RETURN-MESSAGE.
ENDLOOP.IF SY-SUBRC <> 0. "没有发送错误WRITE:'采购订单修改成功!'.COMMIT WORK AND WAIT.
ELSE.WRITE:'采购订单修改失败!'.ROLLBACK WORK.
ENDIF.
运行结果
修改交货日期
代码
*&---------------------------------------------------------------------*
*& Report Z_BAPI_PO_CHANGE
*&---------------------------------------------------------------------*
*& Creator:LiuHongyu
*& Create On:2024.12.24 17:04:09
*& Type:
*& Description:采购订单修改BAPI调用-BAPI_PO_CHANGE
*&---------------------------------------------------------------------*
* Changed History
*-------------- --------------- ------------------ --------------*
* Version Changed By Changed Date Description
*-------------- --------------- ------------------ --------------*
* N LiuHongyu 24.12.2024 17:04:09
*&---------------------------------------------------------------------*REPORT Z_BAPI_PO_CHANGE.DATA PURCHASEORDER TYPE BAPIMEPOHEADER-PO_NUMBER.
DATA POITEM TYPE STANDARD TABLE OF BAPIMEPOITEM.
DATA POITEMX TYPE STANDARD TABLE OF BAPIMEPOITEMX.
DATA RETURN TYPE STANDARD TABLE OF BAPIRET2.
DATA LS_POITEM TYPE BAPIMEPOITEM.
DATA LS_POITEMX TYPE BAPIMEPOITEMX.
DATA LS_POSCHEDULE TYPE BAPIMEPOSCHEDULE.
DATA LS_POSCHEDULEX TYPE BAPIMEPOSCHEDULX.
DATA LT_POSCHEDULE TYPE TABLE OF BAPIMEPOSCHEDULE.
DATA LT_POSCHEDULEX TYPE TABLE OF BAPIMEPOSCHEDULX.PURCHASEORDER = '4500005963'. "采购订单BAPILS_POITEM-PO_ITEM = '00010'.
LS_POITEM-QUANTITY = 10.
APPEND LS_POITEM TO POITEM.LS_POITEMX-PO_ITEM = '00010'.
LS_POITEMX-QUANTITY = 'X'.
APPEND LS_POITEMX TO POITEMX."交货计划
LS_POSCHEDULE-PO_ITEM = '00010'.
LS_POSCHEDULE-SCHED_LINE = 1.
LS_POSCHEDULE-DELIVERY_DATE = '20291001'.
APPEND LS_POSCHEDULE TO LT_POSCHEDULE."交货计划的更改计划行
LS_POSCHEDULEX-PO_ITEM = '00010'.
LS_POSCHEDULEX-SCHED_LINE = 1.
LS_POSCHEDULEX-PO_ITEMX = 'X'.
LS_POSCHEDULEX-SCHED_LINEX = 'X'.
LS_POSCHEDULEX-DELIVERY_DATE = 'X'.
APPEND LS_POSCHEDULEX TO LT_POSCHEDULEX.CALL FUNCTION 'BAPI_PO_CHANGE'EXPORTINGPURCHASEORDER = PURCHASEORDERTABLESRETURN = RETURNPOITEM = POITEMPOITEMX = POITEMXPOSCHEDULE = LT_POSCHEDULEPOSCHEDULEX = LT_POSCHEDULEX.LOOP AT RETURN INTO DATA(LS_RETURN) WHERE TYPE = 'E' OR TYPE = 'A'.WRITE:LS_RETURN-MESSAGE.
ENDLOOP.IF SY-SUBRC <> 0. "没有发送错误WRITE:'采购订单修改成功!'.COMMIT WORK AND WAIT.
ELSE.WRITE:'采购订单修改失败!'.ROLLBACK WORK.
ENDIF.