IBM i (AS/400) DB2 SQL Data Extraction Script Generator
Anyone who has had to move data off an IBM i knows the first problems: what columns does the file have, how many rows are there, and what does that Julian date mean? This generator produces the DB2 for i SQL for those first steps, with JD Edwards style Julian date handling built in.
Fill in
The library that holds the physical file.
For example a JD Edwards World file.
A date stored as a CYYDDD number, century offset then day of year.
124001 is 1 January 2024. Add 100 per century digit: 1 means 20xx.
124366 covers the full leap year 2024.
1. Confirm the file and list its columns
SELECT COLUMN_NAME, DATA_TYPE, LENGTH, NUMERIC_SCALE, COLUMN_TEXT FROM QSYS2.SYSCOLUMNS WHERE TABLE_SCHEMA = 'PRODDTA' AND TABLE_NAME = 'F0911' ORDER BY ORDINAL_POSITION;
2. Count rows
SELECT COUNT(*) AS TOTAL_ROWS FROM PRODDTA.F0911;
3. Count rows in the date range
SELECT COUNT(*) AS ROWS_IN_RANGE FROM PRODDTA.F0911 WHERE GLDGJ BETWEEN 124001 AND 124366;
4. Test extract with a converted date
SELECT GLDOC, GLDCT, GLDGJ, GLAID, GLAA, GLEXA,
CASE WHEN GLDGJ > 0
THEN DATE(CHAR(1900000 + GLDGJ))
ELSE NULL END AS CALENDAR_DATE
FROM PRODDTA.F0911
WHERE GLDGJ BETWEEN 124001 AND 124366
ORDER BY GLDGJ
FETCH FIRST 1000 ROWS ONLY;5. Reconcile row counts by month (optional)
SELECT MONTH(DATE(CHAR(1900000 + GLDGJ))) AS MONTH_NO,
COUNT(*) AS ROW_COUNT
FROM PRODDTA.F0911
WHERE GLDGJ BETWEEN 124001 AND 124366
GROUP BY MONTH(DATE(CHAR(1900000 + GLDGJ)))
ORDER BY MONTH_NO;Run in Run SQL Scripts (ACS), STRSQL or a JDBC client. Verify library, file and column names on your release, as World file layouts differ between versions and local modifications. JD Edwards money fields are usually stored without a decimal point, so check the data dictionary for the implied decimals before using amounts. Always test with a row limit and use a read-only user.
Optional help with a full data extraction
If you need to extract and reconcile years of IBM i data, we can discuss a controlled, read-only approach.
Optional. The tool and every export work without this. No spam.
How to use the generator
Enter the library and file name, the Julian date column, the date range and the columns you want. The tool fills five scripts: a column list from QSYS2.SYSCOLUMNS, a total row count, a count for the date range, a test extract with a calendar date added, and a monthly count for reconciliation. Copy them into Run SQL Scripts in IBM i Access Client Solutions, or into any JDBC client. Run the count queries first so you know the size before you extract.
How the Julian date works
JD Edwards stores many dates as a number in CYYDDD format. C is a century offset from 1900, YY is the year and DDD is the day of the year. So 124001 is the first day of 2024 and 099365 is the last day of 1999. To convert, add 1900000 to get a seven digit year plus day number, such as 2024001, which DB2 for i accepts as a Julian date string. The script guards against zero so that empty dates do not raise errors.
- C = 0 for 19xx, 1 for 20xx
- 124001 = 2024, day 1
- A value of 0 means no date
Common mistakes
People most often forget the implied decimals on amount fields, so a value of 12550 may be 125.50. They also run a heavy extract during the batch window, or against a production library without a row limit. Another mistake is exporting without reconciling: compare row counts and control totals by period against the source before and after the move. Use the monthly count script for that. For very large files, extract in date slices and keep the same selection rules for each run.
Frequently Asked Questions
How do I convert a JDE Julian date in SQL?
Add 1900000 to the CYYDDD value and cast the result to a character string, then pass it to DATE. For example, DATE(CHAR(1900000 + GLDGJ)). Guard against zero values, which represent blank dates.
Where do I run these queries?
In IBM i Access Client Solutions Run SQL Scripts, in STRSQL on a 5250 session, or through a JDBC or ODBC client. Use a user with read-only authority to the data library for safety.
Why are my amounts wrong by a factor of 100?
JD Edwards stores amounts as integers with implied decimals, often two. Check the file definition or the data dictionary for the decimal places and divide accordingly in your extract.
Can I export the result to CSV?
Yes. Run SQL Scripts can save results to a file, and many tools can write CSV from a JDBC connection. For large volumes, use a scripted export in slices and verify counts against the source.
If you need an extraction pipeline for a full migration, with reconciliation and a read-only approach, Netray can discuss it. These scripts work without contact.
Related Tools
JD Edwards World Key File Reference Table
A searchable lookup of widely used JD Edwards World files with the module, purpose and key field prefix, useful for queries, reports and migration mapping.
ERP Migration & SelectionJDE World to E1 Migration Readiness Assessment
Ten questions that show how complicated a JD Edwards World to E1 (or other ERP) move will be, based on customization, data, interfaces and people.
OracleJDE World DREAM Writer Version Documentation Template
Document a DREAM Writer program version, its processing options, data selection, sequencing and output in a form that survives staff changes and migration projects.
ERP OperationsIBM i (AS/400) System Health Check Checklist
A practical weekly and monthly health check for IBM i partitions running ERP such as JD Edwards World, covering storage, jobs, patches, security and recovery.
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
New to IBM i (AS/400) ERPs? Start with the IBM i (AS/400) ERPs guide and toolkit.
Keep exploring
Free tools
- JD Edwards World F0011 Batch Control Status SQL Generator (Db2 for i)Generate Db2 for i SQL that lists F0011 batch headers by type, status and date, decodes status through UDC 98/IC and counts unposted F0911 lines per batch.
- Db2 for i SQL Services Query GeneratorFill in a library, object type and subsystem and get a set of QSYS2 SQL services queries for sizes, row counts, jobs, locks and user profiles.
- JD Edwards World and IBM i Change Request Form TemplateFill-in change request form for program, PTF, system value or data changes with backout plan and approval lines, exported as a clean document.
ERP fixes and how-tos
- How to Add a Private AI Layer to JD Edwards World on IBM iAdd AI to JD Edwards World without moving data: DB2 for i access, journal-based replication, rebuilt row security, local GPUs and approved batch write-back.
- How to Add AI to MAPICS and Infor XA on IBM i Without Leaving Your NetworkHow to give MAPICS and Infor XA on IBM i a private AI assistant: DB2 for i access, journal-based change capture, local GPU model, authority mapping and rollout.
- JDE Work Order Routing: The F3112 Routing File and How It Attaches to a Work OrderHow JD Edwards work order routing works: the F3112 routing file, how the F3003 master routing copies onto a work order, setup steps and SQL to inspect it.
Runs with your ERP
- RF-SMART Manufacturing Data Collection for JD Edwards WorldShop floor barcode data collection for JD Edwards World with RF-SMART: what it reports, how it connects, setup steps, pitfalls and a private AI layer on top.
- Vertex Tax Connectors with JD Edwards EnterpriseOneHow Vertex calculates sales, use and VAT tax for JD Edwards EnterpriseOne and World, plus Oracle EBS and Cloud ERP: integration model, flows, setup, pitfalls.
- RF-SMART and JD Edwards EnterpriseOne: Barcode Scanning and Mobile WMSHow RF-SMART connects barcode scanning to JD Edwards EnterpriseOne and World: integration method, data flows, setup steps, pitfalls and where private AI helps.
AI on your ERP
- AI for JD Edwards World on IBM i, without a EnterpriseOne migrationAdd AI to JD Edwards World on IBM i without replatforming: read the physical files safely, ground an LLM on your data, and keep control on the box you already run.
- AI for JD Edwards EnterpriseOne Manufacturing, Without Leaving the F-Tables ExposedGrounded AI over JD Edwards EnterpriseOne Manufacturing: work orders, routings, and Orchestrator data, answered on-prem without sending F-table data to a public model.
Integrations
- How to connect Power BI to JD Edwards WorldConnect Power BI to JD Edwards World on IBM i: ODBC and gateway setup, a staging layer for Julian dates, key manufacturing dashboards, and natural-language Q&A.
- How to add AI agents to JD Edwards World on IBM iHow to add AI agents to JD Edwards World on IBM i: a read-first tool layer over DB2 for i, human approval before any write, and a fully on-prem model option.