md04 取数函数
DATA: BEGIN OF mdezx OCCURS 0. INCLUDE STRUCTURE mdez. DATA: END OF mdezx. DATA: BEGIN OF mdpsx OCCURS 0. INCLUDE STRUCTURE mdps. DATA: END OF mdpsx. DATA: BEGIN OF mdsux OCCURS 0. INCLUDE STRUCTURE mdsu. DATA: END OF mdsux. DATA:WA_MT61D TYPE MT61D, WA_mdkp TYPE mdkp . PARAMETERS :P_MATNR TYPE MAKT-MATNR, P_WERKS TYPE MARC-WERKS. *LOOP AT itab0. * PERFORM get_md04_data USING itab0-matnr itab0-werks. * MOVE-CORRESPONDING itab0 TO i_out. * LOOP AT mdezx WHERE plaab = '02'. * excess = excess + mdezx-mng01. "可用库存 * IF mdezx-delb0 = 'Stock' OR mdezx-delkz = 'QM'. * stock = stock + mdezx-mng01. "Stock * ENDIF. * IF mdezx-plumi = '-'. "Demand * total_demand = total_demand + mdezx-mng01 * -1. * ELSE. * IF mdezx-delkz = 'LA' "shipping notification * OR mdezx-delkz = 'LE' "Normal PO * OR mdezx-delkz = 'BE'. "SA schedule line * open_po = open_po + mdezx-mng01. "Open PO * ENDIF. * ENDIF. *ENDLOOP. *FORM get_md04_data USING p_matnr p_werks. * CLEAR: mdpsx,mdezx,mdsux. CLEAR: mdpsx[],mdezx[],mdsux[]. CALL FUNCTION 'MD_STOCK_REQUIREMENTS_LIST_API' EXPORTING matnr = p_matnr werks = p_werks importing e_mt61d = wa_mt61d "物料主记录: MRP e_mdkp = wa_mdkp "MRP 凭证的抬头数据 TABLES mdpsx = mdpsx "MRP凭证中的项目 mdezx = mdezx "MRP要素的个别行 mdsux = mdsux "MRP元素全部的行 EXCEPTIONS material_plant_not_found = 1 plant_not_found = 2. *ENDFORM. " GET_MD04_DATA LOOP AT MDPSX. WRITE:/ MDPSX-KDAUF,MDPSX-BAUGR,MDPSX-CUOBJ,MDPSX-EMATN,MDPSX-MDMAT. ENDLOOP. LOOP AT MDEZX. WRITE:/ MDEZX-MDMAT. ENDLOOP. LOOP AT MDSUX. ENDLOOP.