MM Tables in SAP: An In-Depth Overview and SQL Query Examples
The Materials Management (MM) module in SAP is designed to support the procurement and inventory functions occurring in day-to-day business operations. This module ensures that there is no shortage of materials or any gaps in the supply chain process of the organization. Understanding the key MM tables in SAP, their interconnections, and how to retrieve information using SQL queries is essential for anyone working with SAP’s backend database.
Key MM Tables in SAP
- MARA (General Material Data)
- Contains general data about materials such as material type, industry sector, and base unit of measure.
- MAKT (Material Descriptions)
- Stores descriptive texts for materials in different languages.
- MARC (Plant Data for Material)
- Holds data specific to each plant, such as procurement type, MRP type, and production scheduling profile.
- MARD (Storage Location Data for Material)
- Contains information on inventory levels at different storage locations.
- MKPF (Material Document Header)
- Stores header information for material documents, including document number, posting date, and document date.
- MSEG (Material Document Segment)
- Holds line item details for material documents, such as material number, quantity, and movement type.
- EBAN (Purchase Requisition)
- Stores information about purchase requisitions, including requisition number, item, material, and quantity.
- EKPO (Purchasing Document Item)
- Contains item-level details for purchasing documents like purchase orders, including material number, quantity, and price.
- EKKO (Purchasing Document Header)
- Holds header information for purchasing documents, such as purchase order number, vendor, and document date.
How These Tables Are Interconnected
The MM tables in SAP are interconnected through key fields that allow for efficient data retrieval and management. Here’s how they typically relate to each other:
- Material Number (MATNR): This is the primary key that links tables like MARA, MAKT, MARC, and MARD.
- Document Number (MBLNR): Connects the material document header (MKPF) with the material document segments (MSEG).
- Purchase Requisition Number (BANFN): Links the purchase requisition table (EBAN) with other related tables.
- Purchase Order Number (EBELN): Connects purchasing document headers (EKKO) with purchasing document items (EKPO).
Learn about FI tables in SAP
Example SQL Queries
- Retrieve Basic Material Information
To get basic information about materials, including descriptions and plant-specific data, join MARA, MAKT, and MARC:
SELECT
MARA.MATNR AS Material_Number,
MARA.MTART AS Material_Type,
MAKT.MAKTX AS Material_Description,
MARC.WERKS AS Plant,
MARC.DISMM AS MRP_Type
FROM
MARA
JOIN
MAKT ON MARA.MATNR = MAKT.MATNR
JOIN
MARC ON MARA.MATNR = MARC.MATNR
WHERE
MAKT.SPRAS = 'E'; -- Language Key for English
- Retrieve Inventory Levels by Storage Location
To get inventory levels for materials at different storage locations, join MARA and MARD:
SELECT
MARA.MATNR AS Material_Number,
MARA.MTART AS Material_Type,
MARD.WERKS AS Plant,
MARD.LGORT AS Storage_Location,
MARD.LABST AS Stock
FROM
MARA
JOIN
MARD ON MARA.MATNR = MARD.MATNR
WHERE
MARD.WERKS = '1000'; -- Specific Plant
- Retrieve Material Document Details
To get detailed information about material documents, join MKPF and MSEG:
SELECT
MKPF.MBLNR AS Document_Number,
MKPF.BUDAT AS Posting_Date,
MSEG.MATNR AS Material_Number,
MSEG.MENGE AS Quantity,
MSEG.BWART AS Movement_Type
FROM
MKPF
JOIN
MSEG ON MKPF.MBLNR = MSEG.MBLNR
WHERE
MKPF.BUDAT BETWEEN '2023-01-01' AND '2023-12-31'; -- Specific Date Range
- Retrieve Purchase Requisition Information
To get details about purchase requisitions, query the EBAN table:
SELECT
EBAN.BANFN AS Requisition_Number,
EBAN.BNFPO AS Item_Number,
EBAN.MATNR AS Material_Number,
EBAN.MENGE AS Quantity,
EBAN.LFDAT AS Delivery_Date
FROM
EBAN
WHERE
EBAN.WERKS = '1000'; -- Specific Plant
- Retrieve Purchase Order Details
To get comprehensive information about purchase orders, join EKKO and EKPO:
SELECT
EKKO.EBELN AS Purchase_Order_Number,
EKKO.LIFNR AS Vendor,
EKKO.BSART AS Document_Type,
EKPO.EBELP AS Item_Number,
EKPO.MATNR AS Material_Number,
EKPO.MENGE AS Quantity,
EKPO.NETPR AS Net_Price
FROM
EKKO
JOIN
EKPO ON EKKO.EBELN = EKPO.EBELN
WHERE
EKKO.BSART = 'NB'; -- Standard Purchase Order
Conclusion
Understanding the structure and relationships of SAP MM tables is essential for effectively managing materials, inventory, and procurement processes. The tables MARA, MAKT, MARC, MARD, MKPF, MSEG, EBAN, EKPO, and EKKO each play a crucial role in the Materials Management module. By mastering the joins and key fields, you can write efficient SQL queries to retrieve various types of information, aiding in better data analysis and decision-making.
You might be interested to learn about Open sales order table in SAP
2 Comments
Comments are closed.