Thursday, June 19, 2008

SAP MRP List Function Module

SAP MRP List Function Module

To get a MRP list similar to SAP Transaction MD05 you can use the following Function Module.

SAP ABAP Function Module to get MRP list

MD_MRP_LIST_API

The above mentioned Function Module gives MRP List output. For more details on the outputted list please check the following

OutPut Parameters

Structure
MDPS                              Item in MRP document
MDEZ                              Individual lines of the MRP elements
MDSU                             Total lines for MRP elements

Input Parameters

PLSCN                           Planning scenario in long-term planning
MATNR                         Material Number
WERKS                          Plant
BERID                           MRP area
AFIBZ                            Name of display filter
LIFNR                            Vendor Number

Related Tables

MDKP                             Header Data for MRP Document
MDTB                             MRP table
MDTC                             Aggregated MRP table items
T457T                             Description of MRP elements

Related Transaction Code MD05
_____________________________________________________

Please find the code below.

REPORT ZEX_MRPLIST .


Parameter: p_matnr like MARC-MATNR,
           p_werks like MARC-WERKS.


Data: st_MT61D like MT61D,
      st_MDKP  like MDKP,
      int_MDPS TYPE TABLE OF MDPS,
      int_MDEZ TYPE TABLE OF MDEZ,
      int_MDSU TYPE TABLE OF MDSU.


CALL FUNCTION 'MD_MRP_LIST_API'
  EXPORTING
*   PLSCN                          =
    MATNR                          = p_matnr
    WERKS                          = p_werks
*   BERID                          =
*   AFIBZ                          =
*   SINFG                          = 'X'
*   LIFNR                          =
*   AFHOR                          =
*   DTNUM                          =
*   INPER                          =
*   DISPLAY_LIST_MDPSX             =
*   DISPLAY_LIST_MDEZX             =
*   DISPLAY_LIST_MDSUX             =
 IMPORTING
   E_MT61D                        = st_MT61D
   E_MDKP                         = st_MDKP
 TABLES
   MDPSX                          = int_MDPS
   MDEZX                          = int_MDEZ
   MDSUX                          = int_MDSU
 EXCEPTIONS
  MRP_LIST_NOT_FOUND             = 1
   MATERIAL_PLANT_NOT_FOUND       = 2
   ERROR                          = 3
   OTHERS                         = 4
          .
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

SAP Stocks/Requirements List Function Module

SAP Stocks/Requirements List Function Module

To get a list of Stocks/Requirements in SAP, you can use the Function Module given below.

SAP ABAP Function Module to get Stocks/Requirements List.

MD_STOCK_REQUIREMENTS_LIST_API
______________________________________________________


The above mentioned SAP Function Module extracts data that is similar to transaction MD04 (Stocks/Requirement List).

Note: This function module is an RFC (Remote-Enabled Module) this makes it accessible from non-sap systems as well

Related Logical Database MSM

For Logical Database See Also:

Logical DataBase Programs
Logical Database Structure
__________________________________________________________________________________________________________

The Function Module
MD_STOCK_REQUIREMENTS_LIST_API takes the following inputs

PLSCN        Planning scenario in long-term planning
MATNR       Material
WERKS        Plant
BERID         MRP Area
ERGBZ        Selection rule
AFIBZ         Name of display filter
INPER         Internal period indicator
DISPLAY_LIST_MDPSX
DISPLAY_LIST_MDEZX
DISPLAY_LIST_MDSUX
____________________________________________________________________________________________________________

The following Parameters are exported.

Material number, Plant, Deletion Flag, Material description, Material type, Material group, Base unit of measure, Plant-Specific Material Status, MRP type, Procurement Type, Special procurement type, Mixed MRP indicator, Low-level code, Dependent requirements ind. for individual and coll. reqmts, Indicator for Requirements Grouping, MRP controller, Purchasing group, Indicator: MRP controller is buyer (deactivated), In-house production time, Processing time, Setup and teardown time, Interoperation time, Base quantity, Scheduling Margin Key for Floats, Planned delivery time in days, Goods receipt processing time in days, Total replenishment lead time (in workdays), Indicator: automatic fixing of planned orders, Lot size (materials planning), Fixed lot size, Minimum lot size, Maximum lot size, Rounding value for purchase order quantity, Maximum stock level, Assembly scrap in percent, Safety stock, Reorder point, Ordering costs, Storage costs indicator, Forecast indicator, Period indicator, Splitting Indicator, Discontinuation indicator, Effective-Out Date,, Follow-up material, Method for Selecting Alternative Bills of Material, Valuation class, Price control indicator, Moving average price/periodic unit price, Standard price, Price unit, Stock in transfer (plant to plant)

For more Details of the fields see the following

Structure
MT61D
MDPS
MDEZ
MDSU
Transparent Table
MDKP
______________________________________________________________________

See the functional code below.

REPORT ZEX_STOCKREPORT .

Parameter: p_matnr like MARC-MATNR,
           p_werks like MARC-WERKS.


DATA: int_mdpsx  TYPE TABLE OF mdps,
      int_mdezx  TYPE TABLE OF mdez,
      int_mdsux  TYPE TABLE OF mdsu,
      int_mdinx  TYPE TABLE OF mdin.

DATA: wa_mt61d TYPE mt61d,
      wa_mdezx TYPE mdez.

* Initial screen
CALL FUNCTION 'MD_STOCK_REQUIREMENTS_LIST_API'
  EXPORTING
    matnr   = p_matnr
    werks   = p_werks
  IMPORTING
    e_mt61d = wa_mt61d
  TABLES
    mdpsx   = int_mdpsx
    mdezx   = int_mdezx
    mdsux   = int_mdsux
  EXCEPTIONS
    OTHERS  = 1.


    if sy-subrc = 0.

    endif.


See Also:
SAP Availability Check BAPI/Function Module