I would like to share a simple report that can be used to modify the selection screen of MD07.

The program will define a new selection screen. Then it will call the standard MD07.

Remeber that MD07 does not allow the use of multiple selection for Materials:

ZMD071.jpg

This is the selection screen of the new program:

ZMD072.jpg

This is the ABAP code:

*=======================================================================
*———————————————————————–
*  Consulting2b
*———————————————————————–
*  Program:    Z_MD07_RMMD07DB
*  Type:       Report
*———————————————————————–
*  Created By:     Mariano Cabalen
*  Created On:     15/01/2008
*———————————————————————–
*  Description
*  This Program will execute MD07.
*———————————————————————–
*  INPUT :  Internal Table MDMWX has to be filled with
*           material / plant / MRP area combination of
*           selected materials
*———————————————————————–
*  OUTPUT:  MD07 overview of these materials to be processed
*           like in MD07
*———————————————————————–
*=======================================================================

REPORT Z_MD07_RMMD07DB MESSAGE-ID ZMD.

************************************************************************
* VARIABLES DEFINITIONS                                                *
************************************************************************

*–> Type-Pools
TYPE-POOLS: m61x.
*–> DB-Table
TABLES: marc, mara, mdma, eord, pgmi, mkal,
        t000md, mdlv.
*–> Data definitions
CONSTANTS: memo_id_md07(10) TYPE c VALUE ‘START_MD07’.
*–> Structures and Data
DATA: rm61r LIKE rm61r.
DATA:  l_bertx LIKE rm61r-bertx.
*–> Table of selected materials
DATA: BEGIN OF mdmwx OCCURS 0.
        INCLUDE STRUCTURE mdmw.        “material / plant / MRP area
DATA: END OF mdmwx.
*–> Table of selected materials
TYPES: BEGIN OF it_md07,
          MATNR LIKE MDMW-MATNR,
          WERKS LIKE MDMW-WERKS,
          BERID LIKE MDMW-BERID,
          BERTX LIKE MDMW-BERTX,
END OF it_md07.
Types: tb_md07_h type standard table of it_md07.
data: tb_md07 type tb_md07_h WITH HEADER LINE,
      tb1_md07 type tb_md07_h WITH HEADER LINE,
      tb2_md07 type tb_md07_h WITH HEADER LINE,
      tb3_md07 type tb_md07_h WITH HEADER LINE.

************************************************************************
* SELECT-OPTIONS                                                       *
************************************************************************

START-OF-SELECTION.

SELECTION-SCREEN: BEGIN OF BLOCK a1 WITH FRAME TITLE text-001.
SELECT-OPTIONS:
       s_werks FOR rm61r-werks OBLIGATORY,  “Plant
       s_berid FOR rm61r-berid.  “MRP area
SELECTION-SCREEN: END OF BLOCK a1.

SELECTION-SCREEN: BEGIN OF BLOCK a2 WITH FRAME TITLE text-002.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: chk_mat RADIOBUTTON GROUP rad1.
SELECTION-SCREEN COMMENT 3(27) TEXT-R01.
SELECTION-SCREEN END OF LINE.
SELECT-OPTIONS:
       s_matnr FOR rm61r-matnr.  “Material
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: chk_ven RADIOBUTTON GROUP rad1.
SELECTION-SCREEN COMMENT 3(39) TEXT-R02.
SELECTION-SCREEN END OF LINE.
SELECT-OPTIONS:
       s_lifnr FOR eord-lifnr.   “Vendor
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: chk_pro RADIOBUTTON GROUP rad1.
SELECTION-SCREEN COMMENT 3(32) TEXT-R03.
SELECTION-SCREEN END OF LINE.
SELECT-OPTIONS:
       s_prgrp FOR pgmi-prgrp.   “Product Group
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: chk_lin RADIOBUTTON GROUP rad1.
SELECTION-SCREEN COMMENT 3(60) TEXT-R04.
SELECTION-SCREEN END OF LINE.
SELECT-OPTIONS:
       s_mdv01 FOR mkal-mdv01.   “Production Line
SELECTION-SCREEN: END OF BLOCK a2.

SELECTION-SCREEN: BEGIN OF BLOCK a3 WITH FRAME TITLE text-003.
SELECT-OPTIONS:
       s_matkl FOR mara-matkl,   “Material group
       s_dispo FOR rm61r-dispo,  “MRP controller
       s_ekgrp FOR marc-ekgrp,   “Purchasing Group
       s_beskz FOR rm61r-beskz,  “Procurement Type
       s_sobsl FOR rm61r-sobsl,  “Special procurement type
       s_dismm FOR rm61r-dismm,  “MRP Type
       s_mmsta FOR rm61r-mmsta,  “Plant-Specific Material Status
       s_maabc FOR rm61r-maabc.  “ABC indicator
SELECTION-SCREEN: END OF BLOCK a3.

END-OF-SELECTION.

************************************************************************
* PERFORMANCE CHECKS                                                   *
************************************************************************

*–> MRP-Area active ?
PERFORM read_t000md.
IF NOT s_berid IS INITIAL.
  IF t000md-disfg IS INITIAL.
    MESSAGE I001(ZMD).
    EXIT.
  ENDIF.
ENDIF.

*–> Performance Check for Material Selection by Source List
IF chk_ven = ‘X’.
  IF s_lifnr IS INITIAL.
    MESSAGE I000 WITH TEXT-T00.
    EXIT.
  ENDIF.
ENDIF.

*–> Performance Check for Material Selection by Product Group
IF chk_pro = ‘X’.
  IF s_prgrp IS INITIAL.
    MESSAGE I000 WITH TEXT-T01.
    EXIT.
  ENDIF.
ENDIF.

*–> Performance Check for Material Selection by Production Version
IF chk_lin = ‘X’.
  IF s_mdv01 IS INITIAL.
    MESSAGE I000 WITH TEXT-T02.
    EXIT.
  ENDIF.
ENDIF.

************************************************************************
*                       START OF MAIN PROGRAM                          *
************************************************************************

*–> Select all materials by source list
IF chk_ven = ‘X’.
    IF s_berid IS INITIAL.
      SELECT a~matnr
             b~werks
          INTO TABLE tb_md07
          FROM eord AS a
          INNER JOIN marc AS b ON a~matnr = b~matnr
                              AND a~werks = b~werks
          INNER JOIN mara AS c ON a~matnr = c~matnr
          WHERE b~werks IN s_werks  AND a~lifnr IN s_lifnr
            AND a~vdatu <= sy-datum AND a~BDATU >= sy-datum
            AND b~dispo IN s_dispo  AND b~beskz IN s_beskz
            AND b~sobsl IN s_sobsl AND b~dismm IN s_dismm
            AND b~mmsta IN s_mmsta AND b~maabc IN s_maabc
            AND b~ekgrp IN s_ekgrp AND c~matkl IN s_matkl.
    ELSE.
*–> Select all materials in MRP Areas other than plant MRP Area
      IF NOT s_berid IS INITIAL.
        SELECT a~matnr
               b~werks
               c~berid
          INTO TABLE tb_md07
          FROM eord AS a
          INNER JOIN marc AS b ON a~matnr = b~matnr
                              AND a~werks = b~werks
          INNER JOIN mdma AS c ON a~matnr = c~matnr
                              AND a~werks = c~werks
          INNER JOIN mara AS d ON a~matnr = d~matnr
          WHERE b~werks IN s_werks  AND a~lifnr IN s_lifnr
            AND a~vdatu <= sy-datum AND a~BDATU >= sy-datum
            AND b~dispo IN s_dispo  AND b~beskz IN s_beskz
            AND b~sobsl IN s_sobsl AND b~dismm IN s_dismm
            AND b~mmsta IN s_mmsta AND b~maabc IN s_maabc
            AND b~ekgrp IN s_ekgrp AND d~matkl IN s_matkl
            AND c~berid IN s_berid.
      ENDIF.
    ENDIF.
ENDIF.

*–> Select all materials by material
IF chk_mat = ‘X’.
    IF s_berid IS INITIAL.
      SELECT a~matnr
             a~werks
          INTO TABLE tb_md07
          FROM marc AS a
          INNER JOIN mara AS b ON a~matnr = b~matnr
          WHERE a~werks IN s_werks AND a~dispo IN s_dispo
            AND a~beskz IN s_beskz AND a~sobsl IN s_sobsl
            AND a~dismm IN s_dismm AND a~mmsta IN s_mmsta
            AND a~maabc IN s_maabc AND a~matnr IN s_matnr
            AND a~ekgrp IN s_ekgrp AND b~matkl IN s_matkl.
    ELSE.
*–> Select all materials in MRP Areas other than plant MRP Area
      IF NOT s_berid IS INITIAL.
        SELECT a~matnr
               a~werks
               b~berid
          INTO TABLE tb_md07
          FROM marc AS a
          INNER JOIN mdma AS b ON a~matnr = b~matnr
                              AND a~werks = b~werks
          INNER JOIN mara AS c ON a~matnr = c~matnr
          WHERE a~werks IN s_werks AND a~dispo IN s_dispo
            AND a~beskz IN s_beskz AND a~sobsl IN s_sobsl
            AND a~dismm IN s_dismm AND a~mmsta IN s_mmsta
            AND a~maabc IN s_maabc AND b~berid IN s_berid
            AND a~matnr IN s_matnr
            AND a~ekgrp IN s_ekgrp AND c~matkl IN s_matkl.
      ENDIF.
    ENDIF.
ENDIF.

*–> Select all materials by product group
IF chk_pro = ‘X’.
    IF s_berid IS INITIAL.
      SELECT a~nrmit
             a~wemit
          INTO TABLE tb1_md07
          FROM pgmi AS a
          WHERE a~werks IN s_werks AND a~prgrp IN s_prgrp.

      SORT tb1_md07 by werks matnr.

      LOOP AT TB1_MD07.
        SELECT SINGLE matnr werks
              FROM MARC INTO (tb2_md07-matnr, tb2_md07-werks)
              WHERE matnr = tb1_md07-matnr AND werks = tb1_md07-werks
                AND dispo IN s_dispo AND beskz IN s_beskz
                AND sobsl IN s_sobsl AND dismm IN s_dismm
                AND mmsta IN s_mmsta AND maabc IN s_maabc
                AND ekgrp IN s_ekgrp.
        IF SY-SUBRC = 0.
          APPEND tb2_md07.
        ENDIF.
      ENDLOOP.

      SORT tb2_md07 by werks matnr.

      LOOP AT TB2_MD07.
        SELECT SINGLE matnr
              FROM MARA INTO (tb_md07-matnr)
              WHERE matnr = tb2_md07-matnr
                AND matkl IN s_matkl.
        tb_md07-werks = tb2_md07-werks.
        IF SY-SUBRC = 0.
          APPEND tb_md07.
        ENDIF.
      ENDLOOP.

    ELSE.
*–> Select all materials in MRP Areas other than plant MRP Area
      IF NOT s_berid IS INITIAL.
        SELECT a~nrmit
               a~wemit
            INTO TABLE tb1_md07
            FROM pgmi AS a
            WHERE a~werks IN s_werks AND a~prgrp IN s_prgrp.

        LOOP AT TB1_MD07.
          SELECT SINGLE matnr werks
                FROM MARC INTO (tb2_md07-matnr, tb2_md07-werks)
                WHERE matnr = tb1_md07-matnr AND werks = tb1_md07-werks
                  AND dispo IN s_dispo AND beskz IN s_beskz
                  AND sobsl IN s_sobsl AND dismm IN s_dismm
                  AND mmsta IN s_mmsta AND maabc IN s_maabc
                  AND ekgrp IN s_ekgrp.
          IF SY-SUBRC = 0.
            APPEND tb2_md07.
          ENDIF.
        ENDLOOP.

        SORT tb2_md07 by werks matnr.

        LOOP AT TB2_MD07.
          SELECT SINGLE matnr
                FROM MARA INTO (tb_md07-matnr)
                WHERE matnr = tb2_md07-matnr
                  AND matkl IN s_matkl.
          tb_md07-werks = tb2_md07-werks.
          IF SY-SUBRC = 0.
            APPEND tb_md07.
          ENDIF.
        ENDLOOP.

      ENDIF.
    ENDIF.
ENDIF.

*–> Select all materials by production line
IF chk_lin = ‘X’.
    IF s_berid IS INITIAL.
      SELECT a~matnr
             b~werks
          INTO TABLE tb_md07
          FROM mkal AS a
          INNER JOIN marc AS b ON a~matnr = b~matnr
                              AND a~werks = b~werks
          INNER JOIN mara AS c ON a~matnr = c~matnr
          WHERE b~werks IN s_werks  AND a~mdv01 IN s_mdv01
            AND a~adatu <= sy-datum AND a~BDATU >= sy-datum
            AND b~dispo IN s_dispo  AND b~beskz IN s_beskz
            AND b~sobsl IN s_sobsl AND b~dismm IN s_dismm
            AND b~mmsta IN s_mmsta AND b~maabc IN s_maabc
            AND b~ekgrp IN s_ekgrp AND c~matkl IN s_matkl.
    ELSE.
*–> Select all materials in MRP Areas other than plant MRP Area
      IF NOT s_berid IS INITIAL.
        SELECT a~matnr
               b~werks
               c~berid
          INTO TABLE tb_md07
          FROM mkal AS a
          INNER JOIN marc AS b ON a~matnr = b~matnr
                              AND a~werks = b~werks
          INNER JOIN mdma AS c ON a~matnr = c~matnr
                              AND a~werks = c~werks
          INNER JOIN mara AS d ON a~matnr = d~matnr
          WHERE b~werks IN s_werks  AND a~mdv01 IN s_mdv01
            AND a~adatu <= sy-datum AND a~BDATU >= sy-datum
            AND b~dispo IN s_dispo  AND b~beskz IN s_beskz
            AND b~sobsl IN s_sobsl AND b~dismm IN s_dismm
            AND b~mmsta IN s_mmsta AND b~maabc IN s_maabc
            AND c~berid IN s_berid
            AND b~ekgrp IN s_ekgrp AND d~matkl IN s_matkl.
      ENDIF.
    ENDIF.
ENDIF.

*–> Fill Table MDMWX as Selection Table for Lists
      LOOP at tb_md07.
        IF s_berid IS INITIAL.
          mdmwx-matnr = tb_md07-matnr.
          mdmwx-berid = tb_md07-werks.
          mdmwx-bertx = l_bertx.
          mdmwx-werks = tb_md07-werks.
          APPEND mdmwx.
        ELSE.
          mdmwx-matnr = tb_md07-matnr.
          mdmwx-berid = tb_md07-berid.
          mdmwx-bertx = l_bertx.
          mdmwx-werks = tb_md07-werks.
          APPEND mdmwx.
        ENDIF.
      ENDLOOP.

*–> Check: Selektion nichtleer
IF mdmwx[] IS INITIAL.
  MESSAGE e085(61).
ENDIF.

*–> export of table MDMWX to the memory
EXPORT mdmwx rm61r-werks rm61r-dispo rm61r-dspkz rm61r-berid
       TO MEMORY ID memo_id_md07.

*–> Start of dummy-Transaction MDC7, which simulates the entry screen
*    of transaction MD07.
CALL TRANSACTION ‘MDC7’ AND SKIP FIRST SCREEN.

************************************************************************
*                         END OF MAIN PROGRAM                          *
************************************************************************

*&———————————————————————*
*&      Form  read_t000md
*&———————————————————————*
*       text
*———————————————————————-*
*  –>  p1        text
*  <–  p2        text
*———————————————————————-*
*———————————————————————-*
*   Has to be called at the beginning of the transaction
*   T000md-disfg : flag MRP area functionality is active
*———————————————————————-*
FORM read_t000md.
  STATICS:
    done_flag,
    l_t000md LIKE t000md.              “Puffer
  IF done_flag IS INITIAL.
*  check done_flag is initial.
    SELECT SINGLE * FROM t000md.
    IF sy-subrc <> 0.
      CLEAR t000md.
    ENDIF.
    done_flag = ‘X’.
    l_t000md = t000md.
  ELSE.
    t000md = l_t000md.
  ENDIF.
ENDFORM.                               ” read_t000md

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply