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.

SAP PP Books
SAP Production Planning and Control Certification, Interview Questions and Configuration Reference Books

SAP PP Tips
SAP PP Tips and Production Planning/Control

Best regards,
SAP Basis, ABAP Programming and Other IMG Stuff
http://www.erpgreat.com

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.  The site www.erpgreat.com is in no way affiliated with SAP AG.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
 The content on this site may not be reproduced or redistributed without the express written permission of
www.erpgreat.com or the content authors.