Back to Blog
February 17, 2026 min readmicroservices extracting legacy workflow

RPG to Microservices: Extracting Legacy ERP Workflow Secrets

R
Replay Team
Developer Advocates

RPG to Microservices: Extracting Legacy ERP Workflow Secrets

Your enterprise ERP is a black box. Somewhere inside those 40-year-old RPG (Report Program Generator) routines lies the "secret sauce" of your business—the complex pricing logic, the esoteric inventory allocation rules, and the compliance checks that keep your organization running. But the original architects have retired, the documentation is non-existent, and the thought of a "rip and replace" project makes the Board of Directors break out in a cold sweat.

The reality is that 70% of legacy rewrites fail or exceed their timelines because organizations try to translate code they don't fully understand. When you are moving from a monolithic IBM i (AS/400) environment to a modern architecture, the bottleneck isn't writing the new code; it's microservices extracting legacy workflow patterns from a system that lacks a modern API or a clear UI/UX map.

TL;DR: Modernizing RPG-based ERPs fails when teams focus on code-to-code translation. By using Replay for Visual Reverse Engineering, enterprises can record legacy workflows, automatically generate documented React components, and decouple business logic into microservices. This reduces modernization timelines from 18-24 months to just weeks, saving 70% in labor costs.


The Documentation Void: Why RPG Modernization Stalls#

Industry experts recommend that before any migration, a complete functional map must be established. However, according to Replay's analysis, 67% of legacy systems lack any form of up-to-date documentation. In the world of RPG and COBOL, the "documentation" is often the collective memory of a few senior developers who are nearing the end of their careers.

When you attempt a manual rewrite, your developers spend an average of 40 hours per screen just to understand the underlying state transitions. They have to navigate "Green Screens," decipher cryptic variable names like

text
CUST_STR_01_A
, and guess how the UI interacts with the DB2 database. This is why the global technical debt has ballooned to a staggering $3.6 trillion.

Visual Reverse Engineering is the process of capturing the visual output and user interactions of a legacy application to reconstruct its underlying business logic, data flow, and component architecture without needing access to the original source code.

By focusing on the user's journey through the ERP, we can begin the process of microservices extracting legacy workflow secrets. Instead of reading dead code, we observe living processes.


The Strategic Pivot: Microservices Extracting Legacy Workflow#

To move from a monolith to a distributed architecture, you cannot simply "wrap" an RPG program in a REST API. That only moves the technical debt to a different layer. You need to extract the workflow.

Microservices extracting legacy workflow requires a three-tier approach:

  1. Observation: Recording the actual steps a power user takes to complete a task (e.g., "Adjusting a Wholesale Order").
  2. Decomposition: Breaking that recording into discrete functional components (The Order Header, the Line Items, the Tax Calculator).
  3. Reconstruction: Generating modern React components and linking them to new microservices that replace the old RPG subfiles.

Replay facilitates this by converting these recordings into documented React code and Design Systems. Instead of a developer spending a week mapping out a complex ERP screen, the platform does it in minutes.

Comparison: Manual Migration vs. Replay-Assisted Extraction#

FeatureManual Rewrite (RPG to React)Replay Visual Reverse Engineering
Documentation CreationManual, prone to errorAutomated via Flow analysis
Time per Screen~40 Hours~4 Hours
Success Rate30% (Industry Avg)90%+
Architectural InsightDeeply hidden in codeVisually mapped in "Flows"
Cost to EnterpriseHigh ($200k+ per module)Low (70% savings)
Timeline18-24 Months4-12 Weeks

Technical Deep Dive: Mapping RPG Subfiles to React Components#

In the IBM i world, the "Subfile" is the king of the UI. It’s a list-processing structure that handles pagination, selection, and data entry. When microservices extracting legacy workflow data interact with these subfiles, they are often dealing with "state" that is managed entirely by the display file (DSPF).

To modernize this, we use Replay's Library to identify these patterns. The platform sees the grid, understands the pagination logic, and outputs a clean, typed React component.

Example: Legacy RPG Logic Extraction#

Imagine a legacy screen that calculates a discount based on a customer's loyalty tier. In RPG, this might be buried in a 5,000-line monolithic program. Through Visual Reverse Engineering, we capture the input (Customer ID, Order Total) and the output (Discounted Total).

Here is how that extracted logic is transformed into a modern, testable TypeScript service that can live within a microservice:

typescript
// Extracted from Legacy Order Entry Workflow interface DiscountContext { customerTier: 'GOLD' | 'SILVER' | 'BRONZE'; orderValue: number; yearsActive: number; } /** * Service: LoyaltyDiscountService * Purpose: Replicates legacy RPG 'CALCDISC' routine identified via Replay Flow capture. */ export const calculateLoyaltyDiscount = (context: DiscountContext): number => { const { customerTier, orderValue, yearsActive } = context; let discountRate = 0; // Replicated logic from legacy screen behavior if (customerTier === 'GOLD' || yearsActive > 10) { discountRate = 0.15; } else if (customerTier === 'SILVER') { discountRate = 0.10; } // Cap discount at $500 as per legacy business rule const calculatedDiscount = orderValue * discountRate; return Math.min(calculatedDiscount, 500); };

By extracting the logic this way, you ensure that the microservice behaves exactly like the legacy system, maintaining business continuity while moving to a modern stack. For more on this, see our guide on Mapping Legacy State to React Hooks.


Building the Modern UI: From Green Screen to Design System#

Once the workflow is extracted, the next challenge is the UI. Most ERP modernizations fail because the new UI is either "too different" for power users or "too ugly" for modern standards.

Replay's Blueprints editor allows architects to take the captured legacy screens and instantly generate a standardized Design System. This ensures that while the backend is moving to a microservices architecture, the frontend remains consistent, performant, and accessible.

According to Replay's analysis, enterprises that use a centralized Component Library during modernization reduce their frontend bugs by 45%. This is because the components are derived directly from the proven workflows of the legacy system.

Example: Generated React Component from Legacy Recording#

Below is a simplified version of a React component generated by Replay after recording a legacy "Inventory Lookup" workflow.

tsx
import React, { useState, useEffect } from 'react'; import { Table, Badge, Input } from '@/components/ui-library'; import { fetchInventoryStatus } from '@/services/inventoryService'; // Component generated via Replay Visual Reverse Engineering export const InventoryDashboard: React.FC = () => { const [items, setItems] = useState([]); const [searchTerm, setSearchTerm] = useState(''); // The workflow extraction identified that this screen // polls for real-time updates every 30 seconds. useEffect(() => { const loadData = async () => { const data = await fetchInventoryStatus(searchTerm); setItems(data); }; loadData(); }, [searchTerm]); return ( <div className="p-6 bg-slate-50 rounded-xl shadow-sm"> <h2 className="text-2xl font-bold mb-4">Warehouse Inventory</h2> <Input placeholder="Search SKU..." onChange={(e) => setSearchTerm(e.target.value)} className="mb-4" /> <Table> <thead> <tr> <th>SKU</th> <th>Description</th> <th>Stock Level</th> <th>Status</th> </tr> </thead> <tbody> {items.map((item) => ( <tr key={item.id}> <td>{item.sku}</td> <td>{item.desc}</td> <td>{item.qty}</td> <td> <Badge variant={item.qty < 10 ? 'destructive' : 'success'}> {item.status} </Badge> </td> </tr> ))} </tbody> </Table> </div> ); };

This component isn't just a "guess"—it's a direct reflection of the functional requirements captured during the recording phase of microservices extracting legacy workflow patterns.


Decoupling the Monolith: The Strangler Fig Pattern#

You don't modernize a 20-year-old ERP overnight. You use the Strangler Fig pattern. This involves gradually replacing specific functionalities of the legacy system with new microservices until the old system is eventually "strangled" and can be decommissioned.

The key to a successful Strangler Fig implementation is identifying the right boundaries. Microservices extracting legacy workflow data provide the natural seams for these boundaries. If you record a user performing "Accounts Payable," that becomes your first microservice candidate.

  1. Record: Use Replay to capture the "Accounts Payable" workflow.
  2. Analyze: Use Replay Flows to see every API call and state change.
  3. Build: Create the React frontend and the Node.js/Java microservice.
  4. Route: Use a reverse proxy to send "Accounts Payable" traffic to the new service while keeping "Accounts Receivable" on the IBM i.

This incremental approach is why the average enterprise rewrite timeline of 18 months can be compressed into a series of 2-week sprints. To dive deeper into this methodology, read our article on The Strangler Fig in Regulated Environments.


Built for Regulated Industries#

When dealing with Financial Services, Healthcare, or Government systems, security isn't an afterthought—it's the primary constraint. Manual extraction of business logic often leads to security regressions or data leaks.

Replay is built for these environments. With SOC2 compliance, HIPAA-readiness, and On-Premise deployment options, you can perform microservices extracting legacy workflow analysis without your sensitive data ever leaving your controlled environment.

Industry experts recommend that any automated modernization tool must provide a clear audit trail. Replay’s "Blueprints" provide exactly that—a visual and code-based history of how every modern component relates back to the original legacy workflow.


The $3.6 Trillion Opportunity#

Technical debt is not just a line item on a balance sheet; it is an agility killer. Every hour your developers spend maintaining RPG code is an hour they aren't spent innovating. By moving toward a model of microservices extracting legacy workflow, you aren't just updating your tech stack—you're liberating your business logic.

The transition from a monolithic ERP to a fleet of agile microservices is no longer a multi-year gamble. With Visual Reverse Engineering, the path is documented, the code is generated, and the risk is mitigated.

Modernize your legacy systems with the precision of a surgeon rather than the blunt force of a total rewrite.


Frequently Asked Questions#

How does Replay handle complex RPG logic that isn't visible on the UI?#

While Replay focuses on Visual Reverse Engineering, it captures the "side effects" of back-end logic through data changes and UI responses. By recording multiple variations of a workflow, the AI Automation Suite can infer the underlying business rules. For extremely deep "headless" logic, we recommend using Replay in conjunction with database triggers to map the full data lineage.

Can we use Replay if our legacy ERP is on-premise and not web-based?#

Yes. Replay is designed to work with terminal emulators and Citrix-delivered applications. As long as a user can interact with the interface on a screen, Replay can record the workflow and begin the process of microservices extracting legacy workflow patterns. We offer on-premise deployment for highly regulated industries like Defense and Banking.

Does Replay generate "spaghetti code" when converting video to React?#

No. Unlike first-generation "low-code" tools, Replay generates clean, human-readable TypeScript and React code that follows modern best practices. The components are modular, typed, and designed to be integrated into your existing CI/CD pipeline. You own the code; there is no vendor lock-in.

How much time can we really save on a typical ERP screen?#

According to our data, the manual process of documenting, designing, and coding a single complex ERP screen takes roughly 40 hours. With Replay, the recording takes minutes, and the initial code generation is near-instant. Even with manual refinement and testing, the average time per screen drops to 4 hours—a 90% reduction in manual effort.

Is it possible to modernize only parts of our ERP?#

Absolutely. This is the core of the Strangler Fig pattern. Most Replay users start with a single high-value workflow (like "Customer Onboarding" or "Claims Processing"). By microservices extracting legacy workflow secrets one at a time, you can show ROI to stakeholders within weeks rather than years.


Ready to modernize without rewriting? Book a pilot with Replay

Ready to try Replay?

Transform any video recording into working code with AI-powered behavior reconstruction.

Launch Replay Free