REPORT zdemo01.
TABLES:marc.
DATA:BEGIN OF gs_itab,
matnr TYPE marc-matnr,
werks TYPE marc-werks,
delkz TYPE mdtb-delkz,
mng01 TYPE mdtb-mng01, "收货/需求
END OF gs_itab,
gt_itab LIKE TABLE OF gs_itab.
DATA:BEGIN OF gs_marc,
matnr TYPE marc-matnr,
werks TYPE marc-werks,
END OF gs_marc,
gt_marc LIKE TABLE OF gs_marc.
SELECT-OPTIONS:
s_matnr FOR marc-matnr,
s_werks FOR marc-werks.
START-OF-SELECTION.
*&---------------------------------------------------------------------*
*& Form frm_get_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
PERFORM frm_get_data.
PERFORM frm_get_mrp_list.
*&---------------------------------------------------------------------*
*& Form frm_get_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM frm_get_data.
SELECT matnr werks INTO TABLE gt_marc
FROM marc
WHERE matnr IN s_matnr
AND werks IN s_werks.
ENDFORM. "frm_get_data
*&---------------------------------------------------------------------*
*& Form frm_get_mrp_list
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM frm_get_mrp_list.
DATA:lt_mdpsx TYPE TABLE OF mdps, "MRP凭证中的项目
lt_mdezx TYPE TABLE OF mdez, "MRP要素的个别行
lt_mdsux TYPE TABLE OF mdsu, "MRP要素全部的行
ls_mdpsx TYPE mdps, "MRP凭证中的项目
ls_mdezx TYPE mdez, "MRP要素的个别行
ls_mdsux TYPE mdsu. "MRP要素全部的行
LOOP AT gt_marc INTO gs_marc.
REFRESH:lt_mdpsx,lt_mdezx,lt_mdsux.
"调用库存需求清单函数
CALL FUNCTION 'MD_STOCK_REQUIREMENTS_LIST_API'
EXPORTING
matnr = gs_marc-matnr "物料
werks = gs_marc-werks "工厂
TABLES
mdpsx = lt_mdpsx "MRP凭证中的项目
mdezx = lt_mdezx "MRP要素的个别行
mdsux = lt_mdsux "MRP要素全部的行
EXCEPTIONS
material_plant_not_found = 1
plant_not_found = 2
OTHERS = 3.
LOOP AT lt_mdsux INTO ls_mdsux.
gs_itab-matnr = gs_marc-matnr.
gs_itab-werks = gs_marc-werks.
gs_itab-delkz = ls_mdsux-delkz.
* mng01 type mdtb-mng01, "需求数量
APPEND gs_itab TO gt_itab.
ENDLOOP.
ENDLOOP.
ENDFORM. "frm_get_mrp_list
阅读(1647) | 评论(0) | 转发(0) |