Developer ToolsFree generatorPDF, Excel, Word exportSAP S/4HANADiscrete Manufacturing

SAP Quality Notification SQL Query Generator (QMEL and QMFE Pareto)

A defect Pareto is the first chart most quality teams want out of SAP. This generator produces the SQL against the notification header QMEL and its items in QMFE so you can count defects by code group and code, list notifications and rank materials.

Fill in

Q1 customer complaint, Q2 complaint against vendor, Q3 internal problem report in the standard delivery.

The ABAP schema in your HANA database. Often SAPHANADB or SAPABAP1.

Generated code
Download:

Notification list

SELECT h.QMNUM, h.QMART, h.MATNR, h.MAWERK, h.LIFNUM, h.QMDAT
FROM SAPHANADB.QMEL h
WHERE h.MANDT = '100'
  AND h.QMART = 'Q2'
  AND h.MAWERK = '1000'
  AND h.QMDAT >= '20260101'
ORDER BY h.QMDAT DESC;

Defect Pareto by code group and code

SELECT i.FEGRP, i.FECOD, COUNT(*) AS defect_items
FROM SAPHANADB.QMEL h
INNER JOIN SAPHANADB.QMFE i
  ON i.MANDT = h.MANDT AND i.QMNUM = h.QMNUM
WHERE h.MANDT = '100'
  AND h.QMART = 'Q2'
  AND h.MAWERK = '1000'
  AND h.QMDAT >= '20260101'
GROUP BY i.FEGRP, i.FECOD
ORDER BY defect_items DESC;

Notifications by material

SELECT h.MATNR, COUNT(DISTINCT h.QMNUM) AS notifications
FROM SAPHANADB.QMEL h
WHERE h.MANDT = '100'
  AND h.QMART = 'Q2'
  AND h.MAWERK = '1000'
  AND h.QMDAT >= '20260101'
GROUP BY h.MATNR
ORDER BY notifications DESC;

Run read-only on a replica or a reporting copy, never on a production system without a DBA's agreement. Direct database access bypasses SAP authorizations, so restrict who can run it. Verify field names in SE11 for your release. Notification types are configurable, so Q1, Q2 and Q3 may differ in your system. Exclude deleted notifications by joining the status table JEST.

Want a live complaints dashboard?

An optional review of building a read-only quality dashboard over your SAP notification data.

Optional. The tool and every export work without this. No spam.

How to use the generator

Set the client, plant, notification type and the start date, plus the database schema your ABAP tables live in. Copy the three blocks into your SQL console or BI tool. The first block lists the notifications, the second counts defect items by code group and code for a Pareto, and the third ranks materials by number of notifications. Export the result to Excel and sort it descending to draw the classic bar and cumulative line.

How the Pareto works

Each notification can have several items, and each item carries a defect code group FEGRP and code FECOD from the defect catalog. Counting items per code gives the frequency; sorting descending and adding a running percentage shows the vital few codes that account for most defects. The same query run for vendor complaints and for internal problems tells you whether the main issues come from outside or from your own process.

  • Count items, not notifications, when a notification has many defects
  • Use COUNT(DISTINCT QMNUM) when you want the number of notifications
  • Join QMFE on MANDT and QMNUM
  • Translate codes with the code text table QPCT for readable labels

Reading the results

A Pareto with one dominant code points to a focused corrective action, such as a supplier or a specific process step. A flat distribution suggests the coding is too coarse or inconsistent, and the first action is to clean up the catalog. Check also that users code defects at all: a large count of items with a blank code means the data cannot support the analysis.

Common mistakes

Forgetting MANDT in native SQL returns data from every client. Mixing notification types in one Pareto blurs the story. Counting rows after joining causes, tasks and activities as well will inflate numbers, so aggregate each child table separately. Finally, free text defect descriptions cannot be counted, so the catalog discipline matters more than the query.

Frequently Asked Questions

Which table has SAP quality notification defects?

Defect items are in QMFE, joined to the header QMEL by QMNUM and keyed by item number FENUM. The defect code group and code are in the FEGRP and FECOD columns, with texts in the QM code text tables.

What are notification types Q1, Q2 and Q3?

In the standard delivery Q1 is a customer complaint, Q2 a complaint against a vendor and Q3 an internal problem report. Companies copy and rename types, so confirm the list in your own configuration before relying on these values.

How do I get readable defect names instead of codes?

Join the code text table QPCT on catalog type, code group and code, and filter on the language. The catalog type for defects is a configured value, so read it from QMFE or the catalog configuration rather than guessing.

Is it safe to run this on a production HANA database?

Read-only queries are low risk, but direct SQL bypasses SAP authorization checks and can load the system. Use a replica or reporting schema where possible, limit access to named users and agree it with your DBA and security team.

If the real goal is a live quality dashboard or answers to plain-language questions about complaints, we can build that on top of your ERP data with read-only access and the query shown.