Infor M3 SQL Query Generator for Items, Balances and Open Orders
Most M3 reporting questions come down to four queries: which items match a pattern, what is the balance in a warehouse, which customer order lines are still open, and which purchase lines are outstanding for a supplier. This generator fills in the filters and returns SQL you can adapt.
Fill in
Use % as the wildcard
Lines with a lower status are treated as open
1. Item master
SELECT MMCONO, MMITNO, MMITDS, MMITTY, MMITGR, MMUNMS, MMSTAT FROM MITMAS WHERE MMCONO = 100 AND MMITNO LIKE 'AB%' AND MMSTAT = '20' ORDER BY MMITNO;
2. Item balance by warehouse
SELECT MBCONO, MBWHLO, MBITNO, MBSTQT, MBALQT, MBREOP, MBSSQT FROM MITBAL WHERE MBCONO = 100 AND MBWHLO = 'A01' AND MBITNO LIKE 'AB%' ORDER BY MBITNO;
3. Open customer order lines
SELECT H.OAORNO, H.OACUNO, L.OBPONR, L.OBPOSX, L.OBITNO, L.OBORQT, L.OBORST, L.OBDWDT FROM OOLINE L JOIN OOHEAD H ON H.OACONO = L.OBCONO AND H.OAORNO = L.OBORNO WHERE L.OBCONO = 100 AND L.OBWHLO = 'A01' AND L.OBORST < '44' AND L.OBDWDT <= 20261231 ORDER BY L.OBDWDT, H.OAORNO, L.OBPONR;
4. Open purchase order lines for a supplier
SELECT H.IAPUNO, H.IASUNO, L.IBPNLI, L.IBPNLS, L.IBITNO, L.IBPUSL FROM MPLINE L JOIN MPHEAD H ON H.IACONO = L.IBCONO AND H.IAPUNO = L.IBPUNO WHERE L.IBCONO = 100 AND H.IASUNO = 'SUP001' AND L.IBPUSL < '75' ORDER BY H.IAPUNO, L.IBPNLI;
These queries use the standard M3 table and column naming convention. Confirm column names and status values in your release, and note that in M3 Cloud you normally query through Data Fabric or Data Lake object names, which can differ from base table names. Test on a non-production tenant first.
Need M3 reports without the SQL?
We can review your most-used reporting queries and show how plain-language questions would cover them.
Optional. The tool and every export work without this. No spam.
How to use the generator
Enter your company number and warehouse, then set the item pattern and status filters. Copy the block you need into your SQL client, Data Lake query tool or reporting tool. The filters are plain literals so you can see exactly what is being asked; replace them with parameters in production reports.
- Always filter on CONO first
- Use LIKE with a wildcard for item families
- Dates are YYYYMMDD numbers, not date types
Reading the status filters
M3 order and purchase lines carry a status code that rises as the line progresses from entry through allocation, picking, delivery and invoicing. Filtering for a status below a chosen threshold gives open lines. The exact thresholds depend on your order types and configuration, so agree the definition of open with the business before you publish the report.
Common mistakes
Joining header and line tables without the company number can return rows from another company. Another common mistake is sorting dates stored as numbers as if they were text, or comparing them with formatted dates. Finally, direct SQL against a transactional database should be read-only and run off-hours on large tables; many sites prefer an extract into a reporting store.
Frequently Asked Questions
Can I run these queries in M3 Cloud?
Cloud tenants normally expose data through Infor Data Fabric and Data Lake rather than direct database access. The logic is the same, but table and column names in the Data Lake can differ, so adapt the names to the objects you see there.
How do I define an open order line?
Open usually means the line status is below a delivered or invoiced threshold. Because statuses depend on your order type setup, check the status definitions in your configuration and confirm the threshold with the business.
Why are dates numbers in the filters?
M3 stores most dates as eight digit numbers in YYYYMMDD form. Comparing numbers works for ranges, but you must supply the filter in the same format.
Should I write to M3 with SQL?
No. Writes should go through M3 APIs or programs so business rules, statuses and audit data stay consistent. Use SQL for reading only.
If you would rather ask these questions in plain language and see the generated query, ERPray does this over M3 data with read-only access and your existing roles.
Related Tools
Infor M3 Core Database Tables Reference
Look up the main M3 tables, their two-letter column prefix and the key fields you join on. Searchable and exportable.
Infor M3 & CloudSuiteInfor M3 Field Name Glossary
Searchable list of common M3 field codes and what they mean, useful for MI APIs, reports and mapping documents.
Infor M3 & CloudSuiteInfor M3 Bookmark URL Generator
Generate M3 bookmark strings that open a given program on a specific record, with option and panel, for links and mashups.
Infor M3 & CloudSuiteInfor M3 Item Planning Parameter Worksheet
Work out safety stock and reorder point for each item and warehouse before loading planning parameters into M3.
More Infor M3 & CloudSuite tools
See all- Infor M3 Program Reference (MMS001, OIS100, PMS100)
- Infor M3 MI API Transaction Call Generator
- Infor M3 Customer Order Status Tracking Worksheet
- Infor M3 Item Master Upload Worksheet
- Infor M3 MEC Mapping Design Template
- Infor M3 H5 Script Review Checklist
- Infor M3 Upgrade Test Checklist
- Infor M3 Facility and Warehouse Structure Worksheet
- Infor M3 Fit-Gap Analysis Worksheet
New to Infor M3? Start with the Infor M3 guide and toolkit, or plan with Training Path Builder, Upgrade Path Planner, ERP Table and Field Explorer.
Keep exploring
Free tools
- Infor M3 OOHEAD and OOLINE Customer Order Columns ReferenceColumn-level reference for M3 customer order tables OOHEAD and OOLINE and the delivery tables they join to, with keys, joins and the OIS100MI fields that fill them.
- Infor M3 Private AI Layer Blueprint GeneratorFill in your Infor M3 environment and get a ready-to-share architecture plan for a private, on-prem AI assistant.
- Infor M3 AI Assistant Sizing and Value CalculatorSize the GPUs and estimate the monthly value and payback of a private, on-prem AI assistant for Infor M3.
ERP fixes and how-tos
- Private AI Layer for Infor M3 On-Prem: Reference ArchitectureReference architecture to add a private AI assistant to Infor M3 on-prem: data access paths, retrieval, permissions, sizing and rollout, no cloud needed.
- Infor M3 Allocation Table: MITALO Reference and QueriesWhere M3 stores allocations: the MITALO allocation table, how it relates to item balance, query patterns to list allocations and why quantities disagree.
- Infor M3 Master Data: The Core Objects and the Programs That Maintain ThemInfor M3 master data explained: items, customers, suppliers, product structures and operations, which M3 programs maintain them and which tables hold them.
Guides
- AI Distribution Optimization for Infor M3Optimize Infor M3 distribution with AI. Warehouse automation, order fulfillment optimization, and demand forecasting for distribution-intensive operations.
- Infor M3 Distribution Management and Order Fulfillment SetupConfigure Infor M3 distribution management with order processing, warehouse allocation, shipping integration, and customer delivery scheduling best practices.
- Infor M3 Warehouse Management: Setup and Daily FlowHow the Infor M3 warehouse management system works: warehouses, locations, balance IDs, picking, replenishment and cycle counts. A practical setup guide.
AI on your ERP
- Infor M3 Customer Order Management With AI for Status, Allocation and Promise DatesAI for Infor M3 customer order management: answer order status, allocation and delivery date questions from OOHEAD and OOLINE data without exposing it publicly.
- Infor M3 Supply Chain Planning With AI That Explains the MRP OutputAI for Infor M3 supply chain planning: explain MRP action messages, review planned orders, and trace shortages through MITBAL and MITMAS on private infrastructure.
Integrations
- How to use ChatGPT with Infor M3How to use ChatGPT with Infor M3: exports, custom GPT actions over the M3 API or ION, enterprise data controls, and when a private model is the safer choice.
- How to add an AI chatbot to Infor M3How to add an AI chatbot to Infor M3 for staff and customers: grounded in M3 data via the API, embedded in a portal or Teams, and able to run fully on-prem.