Case Studies

IoT-Driven Oil
Replenishment Automation

Case Study
Executive Summary

From sensor reading to purchase order — without a human in the loop

A prominent Australian petroleum distributor supplies fuel to industrial clients across remote and regional sites. Each client site holds large oil tankers fitted with IoT-enabled level sensors from a third-party hardware vendor. The challenge: replenishment orders were being raised manually — operators would check tank levels, decide when to reorder, and create purchase orders by hand in JD Edwards EnterpriseOne. The process was slow, error-prone, and frequently resulted in either emergency top-ups or costly over-ordering.

We designed and built an automated replenishment engine that polls the third-party sensor API on a configurable schedule, evaluates tank levels against per-site thresholds, generates EDI 850 Purchase Order files when replenishment is triggered, and delivers those files to JD Edwards EnterpriseOne through IBM Sterling B2B Integrator. The entire flow — from sensor reading to ERP order — runs without human intervention.

Industry: Oil & Gas · Petroleum Distribution  ·  Stack: Java · Spring Boot · AWS · PostgreSQL  ·  Integration: Third-Party IoT Sensor REST API · EDI X12 850 · IBM Sterling B2B Integrator · JD Edwards EnterpriseOne

The Business Problem

Manual replenishment across dozens of remote sites

The distributor managed fuel supply across a large number of client sites spread across Australia. Replenishment decisions were entirely manual — operators read tank levels, made judgement calls, and entered orders into JD Edwards by hand. The process worked in a small operation, but at scale it was breaking down in predictable ways.

Tank runouts at remote sites

When operators missed a level check — or a site was simply far down the review queue — tanks ran critically low before an order was placed. Emergency replenishment at remote Australian sites carries a significant cost premium.

Over-ordering to stay safe

To avoid runouts, site managers padded order quantities conservatively — tying up working capital in excess stock and creating storage pressure at smaller tank installations.

Manual JD Edwards order entry

Every replenishment order was manually keyed into JD Edwards EnterpriseOne — a repetitive, time-consuming task that added no value and introduced transcription errors that back-office staff had to trace and correct.

No visibility across the sensor network

The third-party sensors were collecting accurate real-time data, but that data lived in the sensor vendor's platform. There was no centralised view of tank levels across sites, and no alerting when levels crossed thresholds.

Scaling the team to scale the operation

Adding new client sites meant adding more monitoring overhead. The only way to grow the distribution network was to grow the operations team — a model that was no longer sustainable.

Technical Challenges

Five hard problems between a sensor and a purchase order

The automation pipeline looks deceptively simple in a diagram. Stitching together a third-party IoT API, a rules engine, an EDI generator, and an enterprise B2B transport layer — reliably, at production scale — is where the real complexity lives.

Sensor API Reliability and Data Quality

The third-party sensor API occasionally returned stale readings, missing fields, or temporary errors due to connectivity issues at remote sites. We implemented a polling layer with configurable retry logic, reading validation (range checks, timestamp freshness), and a per-site circuit breaker that flags anomalous readings for manual review rather than triggering false orders.

Threshold Logic and Duplicate Order Prevention

Threshold evaluation sounds simple until you account for sensor noise — a reading that oscillates around a threshold could trigger multiple orders in a single polling cycle. We built a stateful threshold engine that tracks the last order raised per site, applies a configurable cooldown window, and requires the level to remain below threshold across consecutive readings before triggering. This eliminated duplicate orders entirely.

EDI X12 850 Purchase Order Generation

JD Edwards expects replenishment orders as EDI X12 850 (Purchase Order) files conforming to the client's specific trading partner map — segment ordering, qualifier codes, date formats, and control number sequencing are all part of the contract. We built an EDI generation module that maps the order data to the 850 structure, manages ISA/GS control number sequences with database-backed counters to prevent duplicates across restarts, and validates the generated document against the trading partner spec before dispatch.

IBM Sterling B2B Integrator Transport and Acknowledgement

Sterling acts as the EDI gateway between our system and JD Edwards — files are deposited into a Sterling-monitored mailbox via SFTP, where Sterling picks them up, processes the trading partner envelope, and routes the 850 into JDE. We built a file-delivery layer with delivery confirmation tracking, retry on SFTP failure, and monitoring for functional acknowledgement (997/999) files returned by Sterling to confirm successful processing by the ERP.

Per-Site Configuration and Audit Trail

Each client site has different tank capacities, reorder thresholds, order quantities, lead times, and JD Edwards supplier codes. We built a configuration management layer with a site registry stored in PostgreSQL, allowing thresholds and order parameters to be updated without a deployment. Every sensor reading, threshold evaluation, and order dispatch is written to an immutable audit log — giving operations teams a complete, queryable history of every automated decision the system made.

Solution Architecture

A clean pipeline from sensor to ERP.

The system is built as a scheduled Spring Boot service running on AWS. A polling engine calls the sensor vendor's REST API on a configurable interval, writes readings to PostgreSQL, and passes validated data to the threshold evaluation layer. When a threshold breach is confirmed, the order engine generates an EDI 850 file and delivers it to Sterling via SFTP. Sterling handles the rest — enveloping, routing, and injecting the purchase order into JD Edwards.

Flow: Sensor API → Polling Engine → Threshold Engine → EDI Generator → Sterling SFTP → JD Edwards EnterpriseOne

Discuss Your Integration

IoT Sensor API · Polling Engine · PostgreSQL

The data layer. Scheduled polling calls the third-party sensor REST API per site, validates reading quality, and persists readings with timestamps. A per-site circuit breaker quarantines suspect data before it can affect ordering logic.

Threshold Engine · Order Engine · EDI Generator

The decision and generation layer. Stateful threshold evaluation with cooldown logic determines when to order. The order engine resolves site-specific parameters and passes a structured order model to the EDI generator, which produces a compliant X12 850 file with sequenced control numbers.

IBM Sterling B2B Integrator · JD Edwards EnterpriseOne

The delivery layer. EDI files are deposited via SFTP to Sterling's monitored mailbox. Sterling envelopes and routes the 850 into JDE. Functional acknowledgements (997) are monitored and recorded — any NAK triggers an alert to the operations team.

Key Outcomes

What the operation looks like now

Zero manual order entry for replenishment

Replenishment purchase orders are now raised, formatted as EDI, and delivered to JD Edwards automatically — no operator involvement, no transcription errors, no delays between the trigger event and the order being in the ERP.

Eliminated tank runouts at monitored sites

Since go-live, no monitored site has experienced an unplanned runout. Threshold levels are calibrated per site to account for lead times, so orders are placed with enough runway for delivery — including remote locations with longer transport windows.

Right-sized orders, reduced overstocking

Order quantities are now calculated from actual consumption data rather than conservative estimates. The reduction in safety padding has meaningfully reduced average stock-on-hand and the working capital tied up across the client network.

Full audit trail for every automated decision

Every sensor reading, threshold evaluation, order generation event, and Sterling delivery confirmation is logged to an immutable audit record. Operations and compliance teams can reconstruct the exact sequence that led to any order — down to the millisecond.

New sites added through configuration, not code

Onboarding a new client site requires only a configuration record — sensor ID, threshold, order parameters, JDE supplier code. No deployment, no code change. The distributor can grow their monitored network without any dependency on the development team.

Lessons Learned

What we would tell any team building this kind of system.

IoT-to-ERP automation introduces failure modes that don't exist in conventional software — unreliable physical sensors, strict EDI formatting contracts, and enterprise B2B middleware that expects exact compliance. These are the lessons that shaped how we built this system, and what we'd do from the start on the next one.

Talk to Our Team

Never trust a sensor reading unconditionally

Physical sensors fail, drift, and lose connectivity — especially at remote Australian sites. Design your data ingestion layer to validate every reading before it enters your business logic. A bad sensor reading that bypasses validation can generate a real purchase order.

Understand the EDI spec before you write a line of code

EDI 850 trading partner maps are specific and non-negotiable. Segment ordering, qualifier codes, and control number formats are part of the contract with Sterling. Reverse-engineer the full spec from the client's existing EDI flows before building your generator — changes after your first Sterling test cycle are painful.

Monitor acknowledgements, not just delivery

Depositing a file into Sterling's mailbox is not the same as the order reaching JD Edwards. Functional acknowledgements (997/999) are your only reliable signal that the ERP accepted the transaction. Build acknowledgement tracking from day one — not as a post-launch addition.

bg-cta
cta-main-wrapper

Got sensors and an ERP that don't talk
to each other?
Let's fix that.

If your operations still rely on manual data entry between physical systems and your ERP, we can automate the entire loop. Tell us about your setup and we'll map out the integration.