SQL Query Generator: Controlled Items, Missing Classifications and Foreign Shipments
Most export compliance gaps in an ERP are data gaps: items without a classification, controlled parts on a foreign order, or a license that quietly expired. This generator writes four audit queries you can run against your reporting database.
Fill in
Your item or part table name
Values such as ITAR, EAR, or blank
Illustrative only. Replace with your screened list
1. Active items with no export classification
SELECT i.item_no, i.export_jurisdiction, i.export_class FROM item_master i WHERE i.export_jurisdiction IS NULL OR i.export_jurisdiction = '' OR (i.export_jurisdiction <> 'EAR99' AND (i.export_class IS NULL OR i.export_class = '')) ORDER BY i.item_no;
2. Open order lines for controlled items shipping outside the home country
SELECT l.order_no, l.item_no, i.export_jurisdiction, i.export_class, l.ship_to_country
FROM sales_order_line l
JOIN item_master i ON i.item_no = l.item_no
WHERE l.ship_to_country <> 'US'
AND i.export_jurisdiction IN ('ITAR', 'EAR')
AND i.export_class <> 'EAR99'
AND l.line_status NOT IN ('SHIPPED', 'CLOSED', 'CANCELLED')
ORDER BY l.ship_to_country, l.order_no;3. Any open order to a high risk country
SELECT l.order_no, l.item_no, l.ship_to_country
FROM sales_order_line l
WHERE l.ship_to_country IN ('CN','RU','IR','KP','SY','CU')
AND l.line_status NOT IN ('SHIPPED', 'CLOSED', 'CANCELLED');4. Licenses expiring in the next 60 days
SELECT lic.license_no, lic.expiry_date FROM export_license lic WHERE lic.expiry_date <= CURRENT_DATE + INTERVAL '60 days' AND lic.expiry_date >= CURRENT_DATE ORDER BY lic.expiry_date;
These queries use generic table and column names. Map them to your ERP schema, and adjust date syntax: the interval expression is PostgreSQL style, while SQL Server uses DATEADD and Oracle uses SYSDATE + 60. Statuses and codes differ by system. Run read-only in a reporting copy first. The country list is a placeholder, so use your own screening sources.
Turn these queries into live ERP holds
Optional: we can review how classification data is stored in your ERP and propose a read-only exception report.
Optional. The tool and every export work without this. No spam.
How to use the generator
Enter the table and column names from your ERP schema. For SyteLine, Epicor, SAP or any other system, find where item master data, order lines and any license records live, and type those names in. The output updates as you edit. Copy it to your SQL client and run it against a read-only reporting copy. Export the results to Excel for the compliance owner, who decides what needs correction or a hold.
What each query catches
The first query lists items that have no jurisdiction or classification recorded, which is the root cause of most missed holds. The second joins open order lines to the item master and lists controlled items going outside your country, which are the lines that need a license check or an exemption review. The third shows any open order to the countries on your watch list. The fourth lists licenses about to expire so you can renew or stop shipping.
- Missing classification: fix the item master first
- Controlled item foreign shipments: confirm a license or exemption
- Watch list countries: confirm screening and policy
- Expiring licenses: renew before the next shipment
Limits of a query
A query can flag candidates but cannot decide. A foreign ship-to is not the whole story, because an export can occur through a freight forwarder, a foreign person employee or an emailed drawing. Also check bill-to, end user and intermediate consignee, not only ship-to. Use the output as an input to a documented review, and keep the review record alongside the query result.
Common mistakes
Running ad hoc queries on a production database at peak hours, trusting a blank classification column as meaning not controlled, and hard-coding a country list without a review date. Put the queries in a scheduled report, version them, and assign an owner. Where the ERP supports a hold flag on the item or order, use that for enforcement and keep the query as a safety net.
Frequently Asked Questions
Will these queries work on my ERP?
They work on any SQL database once the table and column names match your schema. Date syntax differs between PostgreSQL, SQL Server and Oracle, so adjust the expiry query. Test in a reporting copy first and confirm the status values your system uses.
Why check items with a blank classification?
A blank means the item was never classified, not that it is uncontrolled. Without a recorded jurisdiction and classification, no hold or license check can fire. Classifying the item master is usually the highest value control you can add.
Does a domestic ship-to mean there is no export?
No. A domestic delivery to a freight forwarder or a foreign person employee can still be an export or deemed export. Look at the end user and intermediate consignees as well as the ship-to address, and consider technical data transfers.
Is the high risk country list authoritative?
No. It is an illustrative default. Build your list from current official sources such as ITAR 126.1, the EAR country groups and OFAC sanctions programs, and put a review date on it.
If you want these checks as a scheduled, read-only report or a live hold inside your ERP, we can build it on your own infrastructure. The generator is free and complete as it stands.
Related Tools
ECCN Structure and Reasons for Control Reference
Read an ECCN like 3A001 or 9A610 piece by piece, with the CCL categories, product groups and reason for control codes listed in one table.
Aerospace & DefenseITAR USML Categories I to XXI Reference
All 21 USML categories with their official titles and a plain summary of what a machine shop, electronics house or software team should look for.
Aerospace & DefenseITAR License, Agreement and DDTC Form Reference
A quick reference to DSP-5, DSP-61, DSP-73, DSP-85, DSP-83, TAA, MLA, WDA and other ITAR authorizations and what each is used for.
Compliance & ContractsExport Control Program Maturity Assessment
Ten questions that score how well your export control program covers classification, screening, licensing, training, records and oversight.
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
- OEE SQL Query GeneratorFill in your table and column names and get a SQL query that calculates availability, performance, quality and OEE per line per day.
- SyteLine SQL Query Generator for Item, Job and Order TablesFill in site, item prefix, job status and date to produce read-only SQL for item master, jobs and open customer order lines.
- MRP Net Requirements SQL GeneratorFill in your table and column names and get a SQL query that computes projected available balance and the shortage per item and bucket.
ERP fixes and how-tos
- Work order (job) item, status and routing tables in SyteLineWhere SyteLine stores work orders (jobs), routings, operations and materials: job, jobroute, jobmatl, jobtran tables, status values and sample SQL queries.
- SYSPRO tables list: core database tables by module and safe queriesSYSPRO database naming, the core tables by module for inventory, sales orders and WIP, and safe read-only SQL patterns for reporting without risking data.
- How to Create an Item in Oracle EBSCreate an inventory item in Oracle EBS: Master Items form, master organization, templates, attributes, organization assignment, categories and common errors.
Guides
- Controlled Unclassified Information in Your ERPWhere CUI hides in a manufacturing ERP: attachments, routings, BOMs, travelers and reports, plus how to scope, permission and audit it for NIST 800-171.
- A Practical Guide to SyteLine's Core SQL TablesA practical guide to the core SyteLine SQL tables, customer orders, lines, items, purchasing, jobs, their join paths, _mst conventions, and site_ref scoping for correct queries.
- SyteLine Multi-Currency Management and Configuration GuideConfigure multi-currency processing in Infor SyteLine including exchange rate tables, currency revaluation, translation, and foreign currency transactions.
AI on your ERP
- AI for ERP in Canada: Controlled Goods, PIPEDA, and On-Prem DesignAI for SAP, Oracle, and Infor ERPs in Canadian aerospace and defense manufacturing: Controlled Goods Program, PIPEDA and Quebec Law 25, and on-prem AI design.
- AI for Infor LN in Aerospace and Defense ManufacturingAI grounded on Infor LN project, contract, and configuration management data for aerospace and defense manufacturers, with on-prem deployment for ITAR.
Manufacturing hubs
- Greater Toronto Area precision machining and aerospace suppliersGuide to precision machining and aerospace suppliers in the Greater Toronto Area: AS9100, NADCAP, Controlled Goods, ecosystem groups, ERP and quoting issues.
- Aerospace, Space and Defense Manufacturing in Denver and the Colorado Front RangeDenver and Colorado Front Range aerospace, space and defense manufacturing: anchor industries, MEP and research ecosystem, compliance, ERP and private AI.