SQL Generator for Receipts Missing a Mill Test Certificate
Pressure equipment buyers expect a mill test certificate for each heat of material, often an EN 10204 type 3.1 certificate. Finding the receipts that arrived without one is a daily quality task, and it should not need a manual spreadsheet. This generator builds the SQL once you tell it your table names.
Fill in
Table with one row per received line.
Table with one row per attached certificate.
Query 1: receipts with no matching certificate
SELECT r.receipt_no,
r.po_number,
r.item_code,
r.heat_number,
r.vendor_code,
r.receipt_date,
DATEDIFF(day, r.receipt_date, GETDATE()) AS days_open
FROM dbo.po_receipt_line r
JOIN dbo.item_master i ON i.item_code = r.item_code
LEFT JOIN dbo.material_certificate c
ON c.item_code = r.item_code
AND c.heat_number = r.heat_number
AND c.cert_type = '3.1'
WHERE i.cert_required = 1
AND r.receipt_date >= '2026-01-01'
AND c.heat_number IS NULL
AND DATEDIFF(day, r.receipt_date, GETDATE()) > 5
ORDER BY days_open DESC;Query 2: count of open gaps by supplier
SELECT r.vendor_code,
COUNT(*) AS lines_without_cert,
MIN(r.receipt_date) AS oldest_receipt
FROM dbo.po_receipt_line r
JOIN dbo.item_master i ON i.item_code = r.item_code
LEFT JOIN dbo.material_certificate c
ON c.item_code = r.item_code
AND c.heat_number = r.heat_number
AND c.cert_type = '3.1'
WHERE i.cert_required = 1
AND r.receipt_date >= '2026-01-01'
AND c.heat_number IS NULL
AND DATEDIFF(day, r.receipt_date, GETDATE()) > 5
GROUP BY r.vendor_code
ORDER BY lines_without_cert DESC;Table and column names are generic placeholders, not the schema of any specific ERP. Map them to your own receipt, certificate and item tables (for example SAP QM certificate tables, Infor SyteLine receiving and lot tables, or a custom table). The T-SQL syntax uses DATEDIFF and GETDATE, adjust for Oracle or PostgreSQL. Test against a copy, and run read only.
Certificate control in your ERP
Optional review of how certificates and heat numbers are linked to receipts and quality holds.
Optional. The tool and every export work without this. No spam.
How to use the generator
Fill in your receipt table, certificate table and item master table, and the column that marks an item as certificate controlled. Choose the required certificate type and the receipt start date. The tool returns two queries: the detail list of receipt lines with no matching certificate, and a summary count by supplier. Copy the SQL into your reporting tool, a database client or a scheduled job that emails the list to supplier quality.
What the query does
The detail query joins each receipt line to the item master to keep only certificate controlled items. It then left joins the certificate table on item and heat number, and keeps rows where no certificate was found. The days open column shows how long the gap has existed, and the grace period removes recent receipts that are still in the normal paperwork window. The summary query groups the same gaps by vendor.
- Join on heat number, not only on item code.
- Match the certificate type the order requires.
- Use a grace period to avoid noise on new receipts.
Adapting to your system
Most ERPs keep lot or heat data in a lot table separate from the receipt line, and certificates as attachments rather than a typed table. In that case join through the lot record and test for the existence of an attachment or a certificate flag. Document the mapping once so the query survives upgrades. For Oracle or PostgreSQL replace the date functions with the platform equivalents.
Common mistakes
Typical errors are matching on item code only, which hides missing certificates when another heat of the same item has one, ignoring partial receipts, and counting a certificate of the wrong type as acceptable. Also avoid running heavy queries against the live transaction database in peak hours, use a reporting replica where possible, and keep the query read only.
Frequently Asked Questions
What is an EN 10204 3.1 certificate?
It is an inspection certificate in which the manufacturer declares compliance with the order and reports test results, validated by the manufacturer's authorized inspection representative who is independent of the production department. Type 3.2 adds validation by a third party or the purchaser's representative.
Can I run this directly on my ERP database?
Only after mapping the table and column names, and preferably against a copy or a reporting replica. The query is read only, but heavy joins on a production database can still affect users. Review it with your DBA first.
Why join on heat number?
The certificate belongs to a heat or lot of material, not to the item code. Joining only on item code could treat a receipt as covered because a certificate exists for a different heat, which is exactly the error the report is meant to catch.
Does the query work for Oracle?
Not as written. It uses T-SQL date functions. In Oracle replace DATEDIFF and GETDATE with date subtraction and SYSDATE, and in PostgreSQL use date subtraction and CURRENT_DATE. The join logic stays the same.
If certificate tracking is manual today, we can help build a read only report or an assistant over your receiving and lot data, with the SQL shown for review.
Related Tools
API 5L Line Pipe Grade Strength Reference
Specified minimum yield and tensile strength for API 5L grades A25 to X80, with ISO 3183 L grade equivalents.
Industry TemplatesOil and Gas Equipment Preservation and Shipping Checklist
Checklist for releasing pressure equipment, valves and wellhead hardware for shipment with preservation, marking and documents verified.
Compliance & ContractsAPI Q1 and ISO 29001 Readiness Assessment
Ten questions to gauge how ready your quality system, records and ERP data are for an API Q1 or ISO 29001 audit.
Industry TemplatesAPI 6A Wellhead Temperature and Material Class Reference
Look up API 6A temperature classes, material classes, rated working pressures and product specification levels in one searchable table.
More Developer Tools tools
See all- SAP Sales Order ABAP SELECT Generator (VBAK, VBAP, VBFA)
- SAP Sales Order Create BAPI ABAP Generator (BAPI_SALESORDER_CREATEFROMDAT2)
- SAP ABAP Open Items SELECT Generator
- SAP ACDOCA SQL Query Generator
- SAP QM Inspection Lot ABAP SELECT Generator
- SAP Quality Notification Pareto SQL Query Generator
- SAP QM Usage Decision BAPI Skeleton
- ABAP Custom Exception Class Generator
- ABAP Unit Test Class Generator
Keep exploring
Free tools
- Material Test Report Checklist (EN 10204 3.1)Checklist for incoming review of mill certificates and MTRs against EN 10204 3.1, covering identification, chemistry, mechanicals and heat treatment.
- SyteLine Open Purchase Order Query GeneratorBuilds a read-only SQL query for open and late PO lines in SyteLine 9/10, with a second query for vendor on-time delivery from PO receipts.
- Oil and Gas Equipment Preservation and Shipping ChecklistChecklist for releasing pressure equipment, valves and wellhead hardware for shipment with preservation, marking and documents verified.
ERP fixes and how-tos
- SyteLine error: no cost record exists for this item at this siteWhy SyteLine blocks a transaction with a missing standard cost or cost element error, and how to fix it via Item Costs, Cost Rollup, and cost effective-dating.
- SYSPRO Analytical Reports and PO ReportingHow to report on SYSPRO purchase orders and run analytical reports: standard PO reports, SRS, SYSPRO Analytics and a SQL query for open commitments and receipts.
Guides
- Certificates of Conformance and Material Traceability for Aerospace PartsWhat goes in an aerospace certificate of conformance, how to trace heat and lot numbers from mill cert to shipped part, and keep records auditors accept.
- Fastener Certs of Conformance and Material Test Reports ExplainedWhat a fastener cert of conformance should contain, how it differs from a material test report, and how to generate certs from lot data without hand-typing.
- Tracking Material Test Reports and Certificates for Valve ManufacturersHow valve manufacturers can link MTRs, heat numbers, PMI and test certificates to each serial number, and cut the time to assemble a customer data book.
AI on your ERP
- AI on Infor SyteLine for Oil and Gas Equipment ManufacturersAI on Infor SyteLine for oil and gas equipment: API Q1 and 6A traceability, MTRs, heat lots, ETO projects, and aftermarket parts. Private deployment.
- AI ERP for Oil and Gas Equipment Manufacturers: Heat Traceability, MTRs and AftermarketPrivate AI on your ERP for wellhead, valve, BOP and pressure equipment manufacturers: heat traceability, MTRs, NDE records, API Q1 and aftermarket service.
Manufacturing hubs
- Manufacturing in Houston, Texas: oil and gas equipment, petrochemical, valves and pumpsHouston manufacturing guide: oil and gas equipment, petrochemical, valves and pumps. Standards, ecosystem, ERP and quoting problems shops face, and where private AI helps.
- Forging Industry Association (FIA): forging processes, standards and ERP realitiesForging Industry Association (FIA): open die, closed die and ring rolling shops, standards, and the ERP, traceability, costing and private AI issues forgers face.
Integrations
- How to add document OCR to SYSPROAdd document OCR to SYSPRO: capture supplier invoices, packing slips and certificates of conformance with confidence thresholds, review and e.net posting.
- How to add document OCR to ProShop ERPCapture supplier invoices, material certs, packing slips and inspection reports into ProShop with OCR, confidence scoring and human review before posting.