Infor System21 DB2 for i SQL Query Generator
This generator writes read-only Db2 for i SQL for Infor System21: sales order header to line joins, orders with the customer master, stock by stockroom, item lookups and records currently locked. Every field name is an editable input so you can match your own file layouts after checking them with DSPFFD.
Fill in
Convention-based; confirm with DSPFFD
Convention-based; confirm with DSPFFD
Convention-based; confirm with DSPFFD
Convention-based; confirm with DSPFFD
OE uses CATN for item number; confirm with DSPFFD
Convention-based; confirm with DSPFFD
Convention-based; confirm with DSPFFD
IN uses PNUM for item number; confirm with DSPFFD
Convention-based; confirm with DSPFFD
0. Inspect the files first (CL commands)
-- Run these on a command line before trusting any field name below -- IBM i commands: -- DSPFFD FILE(OSLD1F3/OEP40) -- DSPFFD FILE(OSLD1F3/OEP55) -- DSPFFD FILE(OSLSLF3/SLP05) -- DSPDBR FILE(OSLD1F3/OEP40) -- System21 commands in OSLSYS (prompt with F4): -- DSPFLD display a file's layout -- DSPKEY display a file's access path -- DSPDEP display all logical files of a physical file
1. Order header to lines
-- Sales order header (OEP40) joined to order lines (OEP55)
SELECT h.*, l.*
FROM OSLD1F3.OEP40 h
JOIN OSLD1F3.OEP55 l
ON l.CONO55 = h.CONO40
AND l.ORDN55 = h.ORDN40
WHERE h.CONO40 = '01'
ORDER BY h.ORDN40
FETCH FIRST 100 ROWS ONLY;2. Orders with customer master
-- Order headers with the customer record from the Sales Ledger (SLP05)
SELECT h.ORDN40, h.CUSN40, c.*
FROM OSLD1F3.OEP40 h
LEFT JOIN OSLSLF3.SLP05 c
ON c.CONO05 = h.CONO40
AND c.CUSN05 = h.CUSN40
WHERE h.CONO40 = '01'
ORDER BY h.ORDN40
FETCH FIRST 100 ROWS ONLY;3. Stock by stockroom for one item
-- Item stockroom balance profile (INP60) for one item SELECT * FROM OSLD1F3.INP60 WHERE PNUM60 = 'ITEM-1001' FETCH FIRST 100 ROWS ONLY;
4. Item master lookup
-- Inventory item master (INP35) SELECT * FROM OSLD1F3.INP35 WHERE PNUM35 = 'ITEM-1001'; -- Order lines for the same item (OE references the item as CATN) SELECT l.* FROM OSLD1F3.OEP55 l WHERE l.CONO55 = '01' AND l.CATN55 = 'ITEM-1001' FETCH FIRST 100 ROWS ONLY;
5. Records currently locked by System21
-- Sales orders held by a user or a failed program (ACTF40 not blank) SELECT ORDN40, ACTF40 FROM OSLD1F3.OEP40 WHERE ACTF40 <> '' FETCH FIRST 100 ROWS ONLY; -- Items held in maintenance (ACTF35 not blank) SELECT PNUM35, ACTF35 FROM OSLD1F3.INP35 WHERE ACTF35 <> '' FETCH FIRST 100 ROWS ONLY; -- Most applications also log locks in control files, for example INP99 SELECT * FROM OSLD1F3.INP99 FETCH FIRST 100 ROWS ONLY;
Verified names from IBM Redbook SG24-5967 chapter 3: files OEP40, OEP55, INP35, INP60, INP99 (OSLD1F3) and SLP05 (OSLSLF3), fields ORDN40, ACTF40, ACTF35, and the convention that OE uses CATN and IN uses PNUM for item number. All other field defaults (CONO40, CUSN40, ORDN55, CONO55, CATN55, CONO05, CUSN05, PNUM35, PNUM60) are placeholders built from the naming convention and must be confirmed with DSPFFD on your system. These queries are read-only. Never update System21 files directly: lock fields and control files would be left inconsistent.
Get your System21 queries checked
Send us your DSPFFD output for the files you report on and we will correct the field names in these queries for your release.
Optional. The tool and every export work without this. No spam.
How to use it
Start with block 0 and run DSPFFD against OEP40, OEP55 and SLP05 in your libraries. Copy the real company, order, customer and item field names into the inputs; the defaults follow the System21 convention of field reference code plus two-digit file number, but only ORDN40 and the lock fields ACTF40 and ACTF35 are confirmed in the source. Set the distribution file library (normally OSLD1F3) and the Sales Ledger file library (normally OSLSLF3), the company code value and a row limit. Then paste the SQL into Run SQL Scripts in IBM i Access Client Solutions or any ODBC tool connected with a read-only profile.
Field naming convention behind the defaults
System21 field names are a short field reference code followed by the last two digits of the physical file number. The order number in the sales order header OEP40 is therefore ORDN40, and the same reference code ORDN appears in other files with their own suffix. The inputs use this rule to suggest CONO40, CUSN40, ORDN55 and so on. Two exceptions catch people out: the OE application refers to the item number as CATN while the IN application uses PNUM, and many General Ledger fields have no suffix at all, such as CONO, TXSRCE, TT and DOCREF that link FLP007 and FLP008.
- OEP40 header, OEP55 lines, OEP65 and OEP70 invoices
- INP35 item master, INP60 stockroom balance
- SLP05 customer master in OSLSLF3
Worked example: finding a stuck order
A user reports that order 123456 cannot be amended. Run block 5: if the order appears with ACTF40 set, System21 still thinks someone is maintaining it, often after a session ended abnormally. Check active jobs for the user first. If no job holds it, the Redbook approach is to clear the lock through a controlled database utility under your support team, and to clear the Application Manager lock with Verify Allocations or the Active Jobs enquiry. Do not clear locks from an SQL script you share with users; record who cleared what and why.
Version notes and gotchas
The source Redbook describes System21 3.5-era layouts; later releases and Aurora can change field lengths or add files, so test each query on a copy first. Company and code fields are usually fixed-length character, so compare with quoted values and watch for leading zeros. If your site has several environments, the libraries may have different names (a test environment might use TSTD1F3 instead of OSLD1F3), so set the libraries for the environment you mean. The Redbook also warns that some fields may be obsolete or reused, so verify any field you report on against real data.
Frequently Asked Questions
How do I join the System21 order header to order lines?
Join OEP40 (header) to OEP55 (lines) in OSLD1F3 on company and order number. The header order number is ORDN40; by the naming convention the line file uses the same reference code with suffix 55. Confirm both field names with DSPFFD, then use block 1 of this generator.
Why does the item number field differ between OE and IN files?
System21 applications have their own field reference files, and they do not always use the same reference code for the same thing. The OE application references item number as CATN, while the IN application uses PNUM. So OEP55 carries a CATN field and INP35 a PNUM field for the same item.
Can I update System21 files with SQL?
Not safely. System21 uses soft locks, lock fields such as ACTF40 and control files such as INP99, and its programs maintain related files together. A direct SQL update skips all of that and can leave balances and locks inconsistent. Keep SQL read-only and make changes through System21 functions.
Which tool should I use to run these queries?
Run SQL Scripts in IBM i Access Client Solutions is the usual choice, and any ODBC or JDBC client works with the IBM i host servers. Use a profile with read authority only to the OSL file libraries you need, and keep the row limit while testing.
If you want planners and customer service to ask System21 these questions in plain English, with read-only SQL on your own IBM i, we can set that up.
Related Tools
Infor System21 Key Application Files and Libraries Reference
The core System21 physical files with their file libraries, application, description and record-lock field, plus the library naming rules you need to find the rest.
Other ERPsInfor System21 Machine Manager Day Start / Day End Schedule Worksheet
An editable worksheet for documenting the System21 Machine Manager Auto Day Start and Auto Day End job streams, prefilled with the jobs suggested in the IBM Redbook.
Developer ToolsInfor XA IBM i SQL Services Health Query Generator
Fill in your XA library, thresholds and subsystem and get five ready-to-run Db2 for i queries for file size, reorganise candidates, inactive users, active XA jobs and history file growth.
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
- Infor System21 Private AI Layer Blueprint GeneratorFill in your Infor System21 version, database, hosting and use cases and get a shareable architecture plan for a private AI layer.
- Infor System21 AI Assistant Sizing and Value CalculatorSize the GPUs and estimate the monthly value and payback of an on-prem AI assistant for Infor System21 users.
- Infor System21 Key Application Files and Libraries ReferenceThe core System21 physical files with their file libraries, application, description and record-lock field, plus the library naming rules you need to find the rest.