REPORT ztest005.
DATA :t_poitem LIKE bapimepoitem OCCURS 0 WITH HEADER LINE .
DATA :t_poitemx LIKE bapimepoitemx OCCURS 0 WITH HEADER LINE .
DATA :t_return LIKE bapiret2 OCCURS 0 WITH HEADER LINE .
DATA : return TYPE TABLE OF bapireturn WITH HEADER LINE .
DATA : lv_frgke LIKE ekko-frgke,
lv_frgsx LIKE ekko-frgsx.
CLEAR t_poitem.
REFRESH t_poitem.
CLEAR t_poitemx.
REFRESH t_poitemx.
CLEAR lv_frgke.
SELECT SINGLE
frgke
frgsx
INTO (lv_frgke,lv_frgsx)
FROM ekko
WHERE ebeln = '4500219546'.
IF lv_frgke = 'R' . " 如果采购订单被批准了,则先取消批准,才能修改
CALL FUNCTION 'BAPI_PO_RESET_RELEASE'
EXPORTING
purchaseorder = '4500219546'
po_rel_code = lv_frgsx
use_exceptions = 'X'
TABLES
return = return.
CLEAR return .
READ TABLE return WITH KEY type = 'E' .
IF sy-subrc EQ 0 .
ENDIF .
ENDIF .
t_poitem-po_item = '00010'.
t_poitem-no_more_gr = 'X' .
APPEND t_poitem.
CLEAR t_poitem.
t_poitemx-po_item = '00010'.
t_poitemx-po_itemx = 'X' .
t_poitemx-no_more_gr = 'X' .
APPEND t_poitemx.
CLEAR t_poitemx.
CALL FUNCTION 'BAPI_PO_CHANGE'
EXPORTING
purchaseorder = '4500219546'
TABLES
return = t_return
poitem = t_poitem
poitemx = t_poitemx.
READ TABLE t_return WITH KEY type = 'E' .
IF sy-subrc EQ 0 .
ROLLBACK WORK .
ELSE .
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ENDIF .
* 如果采购订单被批准了,则先取消批准,修改交货已完成后,在重新设置上批准状态
IF lv_frgke = 'R' .
CALL FUNCTION 'BAPI_PO_RELEASE'
EXPORTING
purchaseorder = '4500219546'
po_rel_code = lv_frgsx
use_exceptions = 'X'
TABLES
return = return.
ENDIF .
ABAP 采购订单 交货已完成BAPI处理
于 2024-11-22 16:53:01 首次发布