用BAPI_MATERIAL_SAVEDATA對MRP Controller(MM01的MRP1檢視中)作change的方法

qiujun發表於2007-10-15

FORM change_mpr_controller .
DATA: st_headdata LIKE bapimathead ,
st_plantdata LIKE bapi_marc ,
st_plantdatax LIKE bapi_marcx ,
st_return LIKE bapiret2 .

LOOP AT it_tab.
CLEAR: st_headdata, st_plantdata, st_plantdatax, st_return.
st_headdata-material = it_tab-matnr .
st_headdata-mrp_view = 'X' .

st_plantdata-plant = it_tab-werks .
st_plantdata-mrp_ctrler = it_tab-new .

st_plantdatax-plant = it_tab-werks .
st_plantdatax-mrp_ctrler = 'X' .

* Call Function to change the MRP Controller.
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
headdata = st_headdata
plantdata = st_plantdata
plantdatax = st_plantdatax
IMPORTING
return = st_return.

IF st_return-type = 'E' OR st_return-type = 'A'.
CLEAR it_err.
MOVE-CORRESPONDING it_tab TO it_err .
it_err-errmg = st_return-message .
APPEND it_err.
CLEAR it_err.
DELETE it_tab INDEX sy-index.

CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.

ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = '1'.
ENDIF.
ENDLOOP.

ENDFORM. " change_mpr_controller

[@more@]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/90072/viewspace-976691/,如需轉載,請註明出處,否則將追究法律責任。

相關文章