In brief
An AI Worker connects to a system on IBM i without rewriting the application: it reads data through SQL views in Db2 for i and writes its proposals to a separate table. Changes to master records are still made by the existing RPG program, and only after a person approves them. The AI Worker has its own user profile with read access to selected views and write access to one table, and every step it takes is journaled. The application's logic and validations stay where they were.
Why not the 5250 screen
The first idea for automating work in an old system is often a robot that clicks through 5250 screens like a person. That works as long as the screen does not change, and on IBM i screens rarely change, so the idea looks safe. The problem lies elsewhere: a robot sees only what fits on the screen, walks through the data record by record and cannot compare thousands of master records at once.
An AI Worker needs something different: read the whole master file, compare records with each other and with external sources, and then describe what it found. The database is the best fit for that. Db2 for i is built into the operating system, and files described in DDS are ordinary tables to SQL, as explained in Db2 for i: SQL instead of DDS.
| Path | What it suits | Limitations |
|---|---|---|
| SQL views over ODBC or JDBC | reading master data, comparisons, reports | read only, writing is handled separately |
| A proposals table | draft changes awaiting approval | needs a program that applies them |
| A REST service over an RPG program | calling existing logic with its validation | it has to be exposed, for example through IWS |
| Files in the IFS | batch exchange, once a day | no real-time confirmation |
| 5250 screens | when there is no other way | slow, brittle, no view of the data as a whole |
REST services over RPG programs are covered in IBM i and modern applications: integration through REST APIs.
Example: cleaning up customer master data
A good first task is the ERP master data keeper, an AI Worker that looks after master data. On an IBM i system its work looks like this:
- It reads customer and item master records through SQL views, plus requests for new records that arrive by email.
- It looks for duplicates among customers and items, for example the same tax ID under two customer numbers, or two items with the same description and unit.
- It flags gaps in mandatory fields: tax ID, unit of measure, weight.
- It checks the tax ID and bank account against the Polish VAT taxpayer register, the "white list" kept by the head of the National Revenue Administration.
- It drafts a new master record from a department's request and saves it as a proposal.
Three things wait for a person: merging duplicates, changing data in a master record and changing a supplier's or customer's bank account. A bank account change always needs approval, because it is a common target for fraud. Every week the team receives a list of errors with ready-made corrections to approve. Cleaning up master data in general is covered in Keeping ERP master data in order.
How to build it on IBM i
The integration consists of three objects in a separate schema and one program that already exists or is added as a short wrapper.
CREATE SCHEMA ai_opiekun;
CREATE VIEW ai_opiekun.kontrahenci AS
SELECT nrkl, nazwa, nip, nrrach, kraj, data_zmiany
FROM app.klienci;
CREATE TABLE ai_opiekun.propozycje (
id INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
nrkl DECIMAL(7, 0) NOT NULL,
pole VARCHAR(30) NOT NULL,
wartosc_jest VARCHAR(100),
wartosc_ma VARCHAR(100),
uzasadnienie VARCHAR(1000) NOT NULL,
status CHAR(1) NOT NULL DEFAULT 'N',
utworzono TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
GRANT SELECT ON ai_opiekun.kontrahenci TO aiopiek;
GRANT SELECT, INSERT ON ai_opiekun.propozycje TO aiopiek;The view exposes only the fields the task needs. The proposals table receives draft changes together with a justification (the column names in the example are Polish: the current value, the proposed value and the reason). A schema created with CREATE SCHEMA has its own journal, so every write to the proposals table is kept in the change history.
Approval happens outside the AI Worker: someone from finance or the data owner reviews the proposals in a list (in a browser or on a 5250 screen) and sets the status to "approved". Only then does the existing RPG master data program, run by a batch job, apply the change. The validations written into that program work exactly as they do when a person makes the change.
Permissions, journaling and data
On IBM i the AI Worker gets the same as a new team member: only what you grant it.
- Its own user profile, without special authorities such as *ALLOBJ, with access only to the ai_opiekun schema. The profile does not sign on to 5250 screens.
- Read access to the views, write access only to the proposals table. The application's files stay out of its reach.
- Audit journal. Object access and profile changes are recorded in the QAUDJRN journal, and changes to the proposals table in the schema's journal. Details in IBM i security.
- Where processing happens. The language model runs on the company's own server or in a data center in Poland. Only the fields needed for the task are sent to the model.
The ODBC connection to the views uses the IBM i Access driver, the same one your reports and spreadsheets already use. The load on the system is small, because the review of master data runs once a week or once a day, outside the night batch window.
Where to start
- Pick one master file, for example customers, and one quality measure: the number of duplicates or of gaps in mandatory fields.
- Prepare an export from recent months for the pilot. The AI Worker works through data from a file before it gets access to the system.
- Compare the results with the team's judgment. How many proposals were accepted without changes, how many were false alarms.
- Only then build the views and the proposals table in a schema on IBM i and connect the approval step.
At DYNAMINDS Labs this path starts with a free diagnosis: a conversation about one process and the data in the system. The pilot usually takes 4 weeks on the company's data, and irreversible decisions, such as changing a supplier's bank account, are always approved by a person. General rules for connecting an AI Worker to ERP programs are covered in AI Workers and ERP.
Questions and answers
Do we need to change RPG programs to connect an AI Worker?
Usually not. The AI Worker reads data through SQL views and writes proposals to a separate table. The existing RPG program applies the changes after approval. Sometimes you need a short program that reads approved proposals and calls the existing logic, but the application itself stays unchanged.
Can an AI Worker corrupt master data?
It has no write access to it. Its profile reads the views and writes only to the proposals table. The change in the master record is made by the application program after a person approves it, with the same validations as when the team works. Every proposal and every approval is journaled.
Does data from IBM i go to an external cloud?
It does not have to. The language model can run on the company's own server or in a data center in Poland. The view exposes only the fields the task needs, so data that is not needed never leaves the database. When personal data is involved, a data processing agreement applies.
Will this work on an older IBM i release?
SQL views, user profiles, journals and ODBC connections have been available for many releases. Before you start, check the OS release and the version of the IBM i Access driver. Newer SQL services make the work easier, but the basic integration does not depend on the latest release.