*&---------------------------------------------------------------------*
*& Report ZSDR100
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZSDR100.
data: I_MRP_PLAN_PARAM like BAPI_MRP_PLAN_PARAM occurs 0 with header line,
I_MRP_STATISTIC like BAPI_MRP_STATISTIC occurs 0 with header line,
I_RETURN like BAPIRET2 occurs 0 with header line,
I_MARA like MARA occurs 0 with header line.
data:I_DISMM like MARC-DISMM,
I_MMSTA like MARC-MMSTA.
initialization.
start-of-selection.
perform GETDATA.
*&---------------------------------------------------------------------*
*& Form getdata
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
form GETDATA.
select * into corresponding fields of table I_MARA
from MARA as a join marc as b
on a~matnr = b~matnr
where ( a~MTART =‘ROH‘ or a~MTART =‘HALB‘or a~MTART =‘FERT‘)
and b~werks = ‘1000‘
and b~DISGR = ‘0001‘."AND MSTAE = ‘‘. "跨工厂物料状态冻结去掉,在物料主档基础数据1视图
refresh: I_MRP_PLAN_PARAM.
I_MRP_PLAN_PARAM-PROC_TYPE = ‘NETCH‘.
I_MRP_PLAN_PARAM-CREATE_PURREQ = ‘2‘.
I_MRP_PLAN_PARAM-CREATE_SCHED_LINES = ‘3‘.
I_MRP_PLAN_PARAM-CREATE_MRP_LIST = ‘1‘.
I_MRP_PLAN_PARAM-PLANNING_MODE = ‘1‘.
append I_MRP_PLAN_PARAM.
loop at I_MARA.
* select single DISMM MMSTA from MARC into (I_DISMM,I_MMSTA)
* where MATNR = I_MARA-MATNR and WERKS = ‘1000‘.
select single DISMM from MARC into (I_DISMM)
where MATNR = I_MARA-MATNR and WERKS = ‘1000‘.
if SY-SUBRC = 4.
continue.
elseif SY-SUBRC = 0.
if I_DISMM = ‘ND‘.
continue.
endif.
* IF i_MMSTA ne ‘‘. “特定工厂物料状态去掉,在MRP视图
* CONTINUE.
* ENDIF.
endif.
call function ‘BAPI_MATERIAL_PLANNING‘
exporting
MATERIAL = I_MARA-MATNR
PLANT = ‘1000‘
* MRP_AREA =
* PLAN_SCENARIO =
MRP_PLAN_PARAM = I_MRP_PLAN_PARAM
* MATERIAL_EVG =
importing
MRP_STATISTIC = I_MRP_STATISTIC
RETURN = I_RETURN.
* TABLES
* MRP_LISTS =
* EXTENSIONOUT =
write at: /2(18) I_MARA-MATNR , 22(220) I_RETURN-MESSAGE.
clear:I_DISMM, I_MMSTA.
clear:I_MARA.
endloop.
endform. "getdata