利用MEMASSPO批量结案采购订单
如下订单订购131个,已交货121个,需要将此订单进行结案,不再收货:
操作如下:
TCODE:MEMASSPO ,查询交货已完成
输入采购订单号和项目号
勾选交货已完成并单击批量更改按钮
保存后提示如下:
ME23N再查询
仍要交货变成0,并且交货已完成被勾上了
case
WHEN 'MEMASSPO'.
DATA: xreturn TYPE BAPIRET2 occurs 0 with header line,
xpoitem TYPE BAPIMEPOITEM occurs 0 with header line,
xpoitemx TYPE BAPIMEPOITEMX occurs 0 with header line.
LOOP at gt_ih into gw_ih.
"Append a row to the internal table xpoitem as
xpoitem-po_item = gw_ih-ebelp. " set position here
xpoitem-no_more_gr = 'X'.
append xpoitem.
"Append a row to the internal table xpoitemx as
xpoitemx-po_item = gw_ih-ebelp. " set position here
xpoitemx-no_more_gr = 'X'.
append xpoitemx.
CALL FUNCTION 'BAPI_PO_CHANGE'
EXPORTING
PURCHASEORDER = gw_ih-ebeln
TABLES
RETURN = xreturn
POITEM = xpoitem
POITEMX = xpoitemx.
IF sy-subrc = 0 .
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'. .
ENDIF.
ENDLOOP.
WHEN 'MEMASSPO'.
DATA: xreturn TYPE BAPIRET2 occurs 0 with header line,
xpoitem TYPE BAPIMEPOITEM occurs 0 with header line,
xpoitemx TYPE BAPIMEPOITEMX occurs 0 with header line.
LOOP at gt_ih into gw_ih.
"Append a row to the internal table xpoitem as
xpoitem-po_item = gw_ih-ebelp. " set position here
xpoitem-no_more_gr = 'X'.
append xpoitem.
"Append a row to the internal table xpoitemx as
xpoitemx-po_item = gw_ih-ebelp. " set position here
xpoitemx-no_more_gr = 'X'.
append xpoitemx.
CALL FUNCTION 'BAPI_PO_CHANGE'
EXPORTING
PURCHASEORDER = gw_ih-ebeln
TABLES
RETURN = xreturn
POITEM = xpoitem
POITEMX = xpoitemx.
IF sy-subrc = 0 .
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'. .
ENDIF.
ENDLOOP.