AI that does real work inside SAP
In my current role I lead the SAP team of a multi-company manufacturer whose ERP has grown since the early 2000s. I use AI for the slow work that blocks an ERP move: reading custom code, writing specs and tests, and making heavy jobs faster. Every result is measured, and a person checks it before it ships.
Current role, 2026. SAP ECC 6.0, a materials shortage report purchasing uses every morning.
A nightly job, four times faster, same output
The report took five and a half hours every night. The first AI pass, given only a plain instruction, brought it under an hour and a half. That was the easy part.
The hard part was proving nothing else changed. Each later build made the code safer, not just faster: identical output, no new ways for the job to fail, step-by-step logging, and one deliberate fix to how it matched MRP data. The final build is also the fastest.
Runtime by build
Every figure is start-to-finish time from the SAP job log, same test variant, all runs on the same day.
Where the remaining time goes
Final build, 12 logged steps
93% of what is left sits in step 7. Logging every step turned "it's slow" into a single target for the next pass.
Current role, 2026. The written instructions ("directives") I give the AI, refined over seven versions.
What made it safe to ship
I don't let the AI decide what "better" means. The directive ranks the goals, and a lower goal can never excuse failing a higher one.
- Identical outputSame rows, same values, same order, same file format.
- Finishes every runNo new way to stop: memory, time limits, authorisation, file errors.
- FasterOnly changes with measured or proven savings.
- Lighter on memoryInside a set budget per run.
Each run produces a review for the SAP developer: every change ranked by how likely it is to alter the output, with intended changes called out. People sign off; the AI doesn't.
Seven versions of one directive
Use arrow keys to step through
A plain instruction
"Optimise this report." Fast results, but no guarantee the output stayed the same and no record of why each change was made.
A written method
The first proper directive: what to read, how to analyse the original before touching it, and what to deliver.
A tiered catalogue
Seven tiers, from shrinking data at the database to statement tuning, applied in that order.
- Lowest memory of all versions: output files are streamed, not held.
- Best balanced score in the head-to-head review.
A stopping rule
Stop adding changes once the next one saves less than 10 minutes or 20 MB; one output file per input file, so reviews stay simple.
A second opinion
The directive was rewritten with a second AI model and compared line by line, to catch blind spots of a single model.
Closest to the original
Fewest routines changed. The right choice when output fidelity matters more than the last few minutes.
Gates and completion fixes
The acceptance order above, plus fixes for ways the original job could already fail.
- Release-aware: only syntax the SAP version actually supports.
- Asks its intake questions once, then works without hand-holding.
- Delivers a bilingual (English and Thai) review, the full source, a test matrix and a rollout plan.
Versions were compared on runtime levers, memory, closeness to the original and completion fixes. The best result was a merge: v7 as the base, plus one idea from v3 and one from the plain-instruction run.
Current role, 2026. Batch job history exported from SAP.
Fix what costs the most, not what's loudest
I picked the first program on instinct. To pick the next ones, I had every retained batch job analysed: 29,824 job-step rows covering 2,581 job hours over about ten days.
Seven programs touch 57% of those hours. The report I started with didn't make the top ten, which says something about instinct. The queue now goes by the numbers, adjusted for business deadlines once process owners confirm them.
Share of job hours, top 12 custom programs
Names generalised
Dark bars are the top seven. Each job counts once per program, so shares overlap where one job runs several programs and don't add up to 100%. Job time includes waiting; it shows exposure, not recoverable savings.
Data and SQL. The part of the work that doesn't show up on a slide.
The SQL and ABAP behind the numbers
Batch tuning and job analytics are database problems first. On the left, the ranking rules above written as SQL. On the right, the single pattern that cost the most time in these reports, before and after.
Ranking rules as SQL
-- T-SQL. One row per program: finished jobs, hours, mean, P95.
WITH finished AS (
SELECT jobname, jobcount,
DATEDIFF(second, start_ts, end_ts) AS elapsed_s
FROM job_header
WHERE status = 'F' -- finished only
AND jobname <> ''
AND end_ts >= start_ts -- crosses midnight safely
),
program_job AS ( -- a job counts once per program
SELECT DISTINCT program, jobname, jobcount
FROM job_step
WHERE program LIKE 'Z%' OR program LIKE 'Y%'
),
ranked AS (
SELECT p.program, f.elapsed_s,
ROW_NUMBER() OVER (PARTITION BY p.program
ORDER BY f.elapsed_s) AS rn,
COUNT(*) OVER (PARTITION BY p.program) AS n
FROM program_job p
JOIN finished f
ON f.jobname = p.jobname AND f.jobcount = p.jobcount
)
SELECT program,
COUNT(*) AS finished_jobs,
ROUND(SUM(elapsed_s) / 3600.0, 2) AS job_hours,
ROUND(AVG(elapsed_s) / 60.0, 1) AS mean_min,
MAX(CASE WHEN rn = CEILING(0.95 * n) -- nearest-rank P95
THEN elapsed_s END) / 60.0 AS p95_min
FROM ranked
GROUP BY program
ORDER BY job_hours DESC, finished_jobs DESC, program;
One read per row, versus one read per batch
" A database round trip for every MRP row
LOOP AT lt_mrp INTO ls_mrp.
SELECT SINGLE ebeln ebelp netpr menge
FROM ekpo
INTO ls_po
WHERE ebeln = ls_mrp-ebeln
AND ebelp = ls_mrp-ebelp.
" ... and five more SELECT SINGLEs on
" EKKO, EINE, EKET, EKES, approvals
ENDLOOP.
" One bulk read per block of keys, then memory
SELECT ebeln ebelp netpr menge
FROM ekpo
INTO TABLE lt_po " HASHED, key ebeln ebelp
FOR ALL ENTRIES IN lt_keys " de-duplicated keys
WHERE ebeln = lt_keys-ebeln
AND ebelp = lt_keys-ebelp.
LOOP AT lt_mrp ASSIGNING FIELD-SYMBOL(<mrp>).
READ TABLE lt_po ASSIGNING FIELD-SYMBOL(<po>)
WITH TABLE KEY ebeln = <mrp>-ebeln
ebelp = <mrp>-ebelp.
ENDLOOP.
From the review of the next report in the queue (shortage with PO, web). These two figures and its projected drop from over 7 hours to under 1 hour are modelled from code and job history, not yet measured in production.
Current role, 2026. Request for AI licences for the SAP team, as operating expense.
An AI business case built on measured hours
I didn't ask for AI on a vendor's slide. I asked for three licences with five finished cases as evidence: what each would have taken by hand, how long the AI ran on its own, and how much people's time it took to direct and check.
Value is counted as extra work capacity at the team's cost rate, not as cash saved. Unproven gains, such as faster ERP vendor discovery, were listed but left out of the total.
Five finished cases, one person, one week
Hours
| Case | By hand | AI alone | People | Gained |
|---|---|---|---|---|
| Optimise the nightly job (above) | 24 | 2 | 4 | 20 |
| Functional specification for it | 10 | 1 | 3 | 7 |
| Test script, 32 cases | 6 | 0.5 | 1.5 | 4.5 |
| Customer ERP integration proposal | 28 | 3 | 7 | 21 |
| Inventory of SAP files by area and age | 16 | 1 | 2 | 14 |
| Total | 84 | 7.5 | 17.5 | 66.5 |
Try it with your own team's numbers
Same formula as the request
Current role, 2026. Company-wide AI policy and use-case review.
Rules before scale
AI is only useful at company scale if legal, security and the business trust it. So the policy, the risk review and the reusable instructions came with the pilot, not after it.
AI policy, English and Thai
Fifteen sections, built on the company's data classification and PDPA duties.
15 use cases, risk-reviewed
12 in use and 3 proposed, each with its risk tier, data rules, approval steps and the policy clauses it relies on.
One rule I hold to: a shared instruction file never replaces approval, connector permissions or the provider's data-retention settings.
12 reusable directives
Written instructions the team runs instead of starting from a blank prompt each time.
The AS-IS blueprint, built the same way, is on the SAP and process page.
Personal project. All figures on this page are invented for illustration.
Off the clock: a personal analytics lab
I run my own investments the way I would run an IT portfolio: one data model, refreshed on a routine, checked for integrity, and turned into a monthly report with a recommendation and a risk register.
The pipeline pulls fund prices into an Excel data model, and an AI-assisted build turns it into a 16-section HTML report: what changed, a scorecard, fund versus index, correlation, macro events, stress tests and a data-integrity check at the end.
What actually moves the portfolio
Correlation of weekly returns, mock data
Hover or tap a cell. Two holdings that move together give less protection than their names suggest.