SAP提供了前台标准事务代码 MM06对单个物料进行各维度删除标记,MM17则可以对物料进行批量的维护了,但是我们在SAP也提供了函数可以对物料进行删除,这样我们就可以不用去录BDC了。
SELECT SINGLE * INTO @DATA(ls_mara) FROM mara WHERE matnr = @lt_tab-matnr.
CLEAR:ls_rm03g.
ls_rm03g-matnr = ls_mara-matnr.
ls_rm03g-lvobw = 'X'.
ls_rm03g-lvoma = 'X'.
ls_rm03g-lvolg = 'X'.
ls_rm03g-lvoln = 'X'.
ls_rm03g-lvolt = 'X'.
ls_rm03g-lvovk = 'X'.
ls_rm03g-lvoba = 'X'.
CALL FUNCTION 'UPDATE_MATERIAL_LVORM'
EXPORTING
chargen_ebene = '1'
imara = ls_mara
imarc = ls_marc
imard = ls_mard
imbew = ls_mbew
imlgn = ls_mlgn
imlgt = ls_mlgt
imvke = ls_mvke
it130s = ls_t130s
rm03g = ls_rm03g
ymbew = ls_ymbew.
在物料层次就可以只对MARA赋值,会自动地将所有维护打上删除标志,如果只是从工厂层次上面去处理,则需要要给MARC赋值,具体可以DEBUG事务MM06,在MM03GF00这里打上断点,具体去看看各维度的区别。
去掉删除标记相对轻松:
CLEAR:ls_rm03g.
ls_rm03g-matnr = ls_mara-matnr.
CALL FUNCTION 'UPDATE_MATERIAL_LVORM'
EXPORTING
chargen_ebene = '1'
imara = ls_mara
imarc = ls_marc
imard = ls_mard
imbew = ls_mbew
imlgn = ls_mlgn
imlgt = ls_mlgt
imvke = ls_mvke
it130s = ls_t130s
rm03g = ls_rm03g
ymbew = ls_ymbew.
注:此方法的删除并不会像MM06那样记录在CDHDR中,所以对自开发的程序请在里面加上日志。
如果需要彻底删除则需要归档。