Powered By

Free XML Skins for Blogger

Powered by Blogger

Wednesday, January 21, 2009

SAP Production Planning - Extract data from MRP Table

*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*
* A sample program to extract data from the MRP table.
*
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
REPORT ZMRPTABLE.

TABLES: MDKP, "Header Data for MRP Document
MDTB, "MRP table
MDTC, "Aggregated MRP table items
T457T. "Description of MRP elements

DATA: BEGIN OF MDTBX OCCURS 0.
INCLUDE STRUCTURE MDTB.
DATA: END OF MDTBX.

SELECT-OPTIONS: PLANT FOR MDKP-PLWRK OBLIGATORY,
MATNR FOR MDKP-MATNR OBLIGATORY.

CLEAR: MDKP, MDTB.
SELECT * FROM MDKP WHERE DTART EQ 'MD'
AND MATNR IN MATNR
AND PLWRK IN PLANT.
WRITE:/ MDKP-MATNR, MDKP-PLWRK.
IF MDKP-CFLAG EQ 'X'.
CLEAR MDTBX. REFRESH MDTBX.
IMPORT MDTBX FROM DATABASE MDTC(AR) ID MDKP-DTNUM.
LOOP AT MDTBX.
MOVE MDTBX TO MDTB.

SELECT SINGLE * FROM T457T WHERE SPRAS = 'E'
AND DELKZ = MDTB-DELKZ.

IF MDTB-PLUMI = '-'. MULTIPLY MDTB-MNG01 BY -1. ENDIF.

WRITE:/ MDTB-DAT00, T457T-DELB1, MDTB-VSTAT,
MDTB-MNG01, MDTB-LGORT.
ENDLOOP.
ELSE.
SELECT * FROM MDTB
WHERE DTNUM EQ MDKP-DTNUM
ORDER BY PRIMARY KEY.
SELECT SINGLE * FROM T457T WHERE SPRAS = 'E'
AND DELKZ = MDTB-DELKZ.

IF MDTB-PLUMI = '-'. MULTIPLY MDTB-MNG01 BY -1. ENDIF.

WRITE:/ MDTB-DAT00, T457T-DELB1, MDTB-VSTAT,
MDTB-MNG01, MDTB-LGORT.
ENDSELECT.
ENDIF.
ENDSELECT.

No comments:

Archives