导语:物料主数据有几部分批导,不能在【BAPI_MATERIAL_SAVEDATA】中实现,例如分类视图批导,这里需要在物料创建成功之后,使用另一个BAPI进行导入。
BAPI名称:MD_MRP_LEVEL_CREATE_DATA、MD_MRP_LEVEL_CHANGE_DATA
BAPI描述:MRP区域创建、修改
前台位置
代码示例
DATA i_matnr TYPE mdma-matnr.
DATA i_werk TYPE mdma-werks.
DATA i_mrp_area TYPE mdma-berid.
DATA i_selfields TYPE sdibe_massfields.
DATA i_mdma TYPE mdma.
DATA i_dpop TYPE dpop.
DATA e_error_return TYPE bapireturn1.
DATA i_berty TYPE mdlv-berty.
CLEAR : i_matnr,i_werk.
CLEAR : i_mrp_area,i_mdma,i_selfields,e_error_return,i_berty.
"创建MRP区域
CLEAR: i_mrp_area,i_mdma,i_selfields,e_error_return,i_berty.
i_matnr = headdata-material.
i_werk = plantdata-plant.
i_mrp_area = mdma-berid.
i_mdma-matnr = i_matnr.
i_mdma-berid = mdma-berid.
i_mdma-dismm = mdma-dismm.
i_mdma-disgr = mdma-disgr.
i_mdma-dispo = mdma-dispo.
i_mdma-eisbe = mdma-eisbe.
i_mdma-disls = mdma-disls.
i_mdma-bstmi = mdma-bstmi.
i_mdma-bstma = mdma-bstma.
i_mdma-bstfe = mdma-bstfe.
i_mdma-bstrf = mdma-bstrf.
i_mdma-sobsl = mdma-sobsl.
i_mdma-lgfsb = mdma-lgfsb.
i_mdma-lgpro = mdma-lgpro.
i_selfields-xdismm = 'X'.
i_selfields-xdisgr = 'X'.
i_selfields-xdispo = 'X'.
i_selfields-xeisbe = 'X'.
i_selfields-xdisls = 'X'.
i_selfields-xbstmi = 'X'.
i_selfields-xbstma = 'X'.
i_selfields-xbstfe = 'X'.
i_selfields-xbstrf = 'X'.
i_selfields-xsobsl = 'X'.
i_selfields-xlgfsb = 'X'.
i_selfields-xlgpro = 'X'.
"判断一下是否已经存在,存在就用修改BAPI
SELECT COUNT(*) FROM mdma WHERE matnr = i_matnr AND berid = i_mrp_area.
IF sy-subrc = 0.
SELECT SINGLE berty INTO i_berty FROM mdlv WHERE berid = i_mrp_area.
CALL FUNCTION 'MD_MRP_LEVEL_CHANGE_DATA'
EXPORTING
i_matnr = i_matnr
i_werk = i_werk
i_mrp_area = i_mrp_area
i_berty = i_berty
i_selfields = i_selfields
i_mdma = i_mdma
i_dpop = i_dpop
IMPORTING
e_error_return = e_error_return.
ELSE.
CALL FUNCTION 'MD_MRP_LEVEL_CREATE_DATA'
EXPORTING
i_matnr = i_matnr
i_werk = i_werk
i_mrp_area = i_mrp_area
i_selfields = i_selfields
i_mdma = i_mdma
i_dpop = i_dpop
IMPORTING
e_error_return = e_error_return.
ENDIF.
IF e_error_return IS INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' "提交该BAPI
EXPORTING
wait = 'X'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ENDIF.
作者:小飞猪猪猪猪猪猪猪–CSDN