Back to Blog
February 10, 20269 min read400 rpg modernization

AS/400 RPG Modernization: Moving Customs and Border Workflows to Modern React Frameworks

R
Replay Team
Developer Advocates

The $3.6 trillion global technical debt crisis is not a theoretical problem for government agencies—it is a daily operational risk. In the high-stakes world of customs and border protection, where milliseconds of latency in manifest processing can lead to supply chain bottlenecks or security lapses, the reliance on decades-old AS/400 RPG (Report Program Generator) systems has reached a breaking point.

Most enterprise leaders are trapped in a false dichotomy: either continue paying the "legacy tax" on a system no one fully understands, or embark on a "Big Bang" rewrite that has a 70% statistical probability of failure. For customs and border workflows, neither is acceptable. The future of 400 rpg modernization is not found in manual code conversion or risky "rip-and-replace" strategies; it is found in Visual Reverse Engineering.

TL;DR: Modernizing critical AS/400 RPG customs workflows no longer requires 24-month high-risk rewrites; Replay uses Visual Reverse Engineering to extract logic and UI into documented React components in weeks, reducing modernization timelines by 70%.

The Failure of "Big Bang" 400 RPG Modernization#

The traditional approach to 400 rpg modernization usually involves hiring a small army of consultants to perform "software archaeology." They spend months interviewing retiring developers and digging through undocumented RPG codebases to map out business logic. Statistics show that 67% of these legacy systems lack any form of usable documentation. In a border security environment, this lack of clarity isn't just a technical debt issue—it’s a compliance and security vulnerability.

The "Big Bang" rewrite fails because it attempts to recreate 30 years of edge cases from scratch. The average enterprise rewrite timeline for a complex customs system is 18 to 24 months. During that time, the business requirements change, the original architects retire, and the project eventually collapses under its own weight.

ApproachTimelineRiskDocumentationCost
Big Bang Rewrite18-24 MonthsHigh (70% fail)Manual/Incomplete$$$$
Strangler Fig12-18 MonthsMediumPost-hoc$$$
Manual Refactoring24+ MonthsHighLow$$$$$
Replay Visual Extraction2-8 WeeksLowAutomated/Real-time$

Moving Customs and Border Workflows to React#

Customs workflows—such as Import/Export Declarations, Tariff Classifications, and Risk Assessment—are notoriously complex. They often involve "green screen" terminal interfaces where the business logic is tightly coupled with the display logic.

When moving these workflows to modern React frameworks, the primary challenge is not the UI; it is the "black box" of business rules hidden within the RPG programs. Replay changes this dynamic by using the video of a real user workflow as the source of truth. Instead of reading the code, Replay records the execution of the workflow, extracts the underlying state transitions, and generates documented React components and API contracts.

Why Visual Reverse Engineering is Superior#

Manual modernization typically requires 40 hours per screen to document, design, and code. With Replay, that time is slashed to 4 hours. This is achieved through three core pillars:

  1. The Library (Design System): Automatically maps legacy UI elements to a modern, accessible React design system.
  2. Flows (Architecture): Visualizes how data moves through the customs manifest process, identifying bottlenecks that were previously invisible.
  3. Blueprints (Editor): An AI-augmented environment where architects can refine the generated code, ensuring it meets strict government standards.

💰 ROI Insight: For a customs agency with 200 critical screens, manual modernization would cost approximately $1.6M in labor alone. Replay reduces this to under $200k while providing 100% documentation coverage.

Technical Deep Dive: From RPG Logic to React Components#

In a typical 400 rpg modernization project, you might encounter fixed-format RPG code that handles complex tariff calculations. Manually translating this into TypeScript is error-prone. Replay’s AI Automation Suite analyzes the recorded workflow to understand how input fields (like "Country of Origin" or "Harmonized System Code") affect the final calculation.

Example: Legacy Business Logic Extraction#

Consider a legacy RPG snippet that calculates customs duties. The goal is to move this into a modern React hook without losing the nuanced edge cases.

typescript
// Generated by Replay: Business logic preserved from AS/400 RPG Workflow // Workflow ID: CUSTOMS_DUTY_CALC_092 // Source System: AS/400 RPG IV interface DutyInput { originCountry: string; hsCode: string; declaredValue: number; } export const useCustomsDuty = () => { const calculateDuty = (data: DutyInput): number => { // Replay extracted these logic branches from user workflow execution let rate = 0.05; // Base rate if (data.originCountry === 'US' || data.originCountry === 'MX') { rate = 0.02; // Trade agreement rate } if (data.hsCode.startsWith('8471')) { rate = 0.00; // Duty-free technology code } return data.declaredValue * rate; }; return { calculateDuty }; };

Example: Generated React Component#

Once the logic is extracted, Replay generates the functional UI component. This isn't just a "skin"—it's a fully typed React component ready for integration into a modern micro-frontend architecture.

tsx
import React, { useState } from 'react'; import { useForm } from 'react-hook-form'; import { useCustomsDuty } from './hooks/useCustomsDuty'; // Component: DeclarationForm // Extracted from: AS/400 Terminal Screen #502 (Import Declaration) export const DeclarationForm: React.FC = () => { const { calculateDuty } = useCustomsDuty(); const [dutyAmount, setDutyAmount] = useState<number>(0); const onSubmit = (data: any) => { const calculated = calculateDuty(data); setDutyAmount(calculated); }; return ( <div className="p-6 bg-white rounded-lg shadow-md"> <h2 className="text-xl font-bold mb-4">Customs Import Declaration</h2> <form onSubmit={onSubmit} className="space-y-4"> {/* Modernized input fields mapped from legacy 5250 terminal positions */} <input name="originCountry" placeholder="Country of Origin" className="border p-2 w-full" /> <input name="hsCode" placeholder="HS Code" className="border p-2 w-full" /> <input name="declaredValue" type="number" placeholder="Value" className="border p-2 w-full" /> <button type="submit" className="bg-blue-600 text-white px-4 py-2 rounded"> Calculate Duty </button> </form> {dutyAmount > 0 && ( <div className="mt-4 p-4 bg-green-50 text-green-700"> Estimated Duty: ${dutyAmount.toFixed(2)} </div> )} </div> ); };

Step-by-Step Guide: Modernizing AS/400 Workflows#

For Enterprise Architects tasked with moving customs systems to the cloud, the process follows a structured path that prioritizes understanding over rewriting.

Step 1: Workflow Recording#

Instead of reading code, record a "Power User" performing the task on the AS/400 terminal. This captures the true business process, including the "workarounds" that developers often miss but are critical for operations.

Step 2: Visual Reverse Engineering#

Replay ingests the recording and breaks it down into state changes, API calls (or terminal commands), and UI patterns. It identifies the "Black Box" logic and generates a Technical Debt Audit.

Step 3: Blueprint Refinement#

Using the Replay Blueprints editor, architects review the extracted React components. Here, you can define API contracts for the new backend (e.g., Node.js or Java Spring Boot) that will eventually replace the RPG backend.

Step 4: Automated Testing Generation#

Replay generates E2E (End-to-End) tests based on the recorded workflow. This ensures that the new React interface behaves exactly like the legacy system, providing 100% parity—a critical requirement for border and customs compliance.

⚠️ Warning: Do not attempt to modernize the database and the UI simultaneously. Use Replay to decouple the UI first, then use the generated API contracts to modernize the data layer.

Security and Compliance in Regulated Environments#

Customs and border agencies operate in highly regulated environments. Any modernization tool must meet stringent security requirements. Replay is built for these high-security scenarios:

  • SOC2 & HIPAA Ready: Ensures data handling meets the highest standards of privacy.
  • On-Premise Availability: For agencies that cannot use the cloud due to national security protocols, Replay can be deployed entirely within an air-gapped environment.
  • Audit Trails: Every component generated is linked back to the original video recording, providing a clear audit trail of why a specific piece of logic was implemented.

📝 Note: In government sectors, "understanding what you have" is a prerequisite for security. Replay’s documentation suite turns the AS/400 from a black box into a documented codebase, reducing the risk of hidden vulnerabilities.

Addressing the Skills Gap#

The average age of an RPG developer is over 50. As this workforce retires, the cost of maintaining AS/400 systems skyrockets. By moving to React, agencies can tap into a massive pool of modern engineering talent. However, the transition must be seamless. Replay bridges this gap by allowing modern developers to work with familiar tools (React, TypeScript, Playwright) while preserving the legacy logic that has powered global trade for decades.

Frequently Asked Questions#

How long does legacy extraction take with Replay?#

While a manual rewrite takes 18-24 months, Replay can extract and document a complex workflow in 2-8 weeks. The actual "recording" of a screen takes minutes; the AI-driven extraction and generation of React components happen in hours.

What about business logic preservation during 400 rpg modernization?#

This is the core strength of Replay. By using "Video as the Source of Truth," Replay captures exactly how the system behaves under real-world conditions. It doesn't just look at the code; it looks at the result of the code, ensuring that complex edge cases in tariff calculations or manifest validation are preserved in the modern React version.

Can Replay handle the "Green Screen" terminal interface?#

Yes. Replay is specifically designed to handle terminal-based interfaces common in AS/400 environments. It maps terminal coordinates and screen-scraping logic into modern, structured data objects and accessible React components.

Does this require a complete migration to the cloud?#

No. Replay allows for a hybrid approach. You can modernize the user interface and workflow logic to React while keeping the data on the AS/400, or you can use Replay's generated API contracts as a roadmap for a full cloud migration later.

How does Replay handle SOC2 and government security requirements?#

Replay offers an On-Premise deployment option, which is essential for government, customs, and border agencies. This ensures that sensitive trade or security data never leaves the agency’s controlled environment during the reverse engineering process.


Ready to modernize without rewriting? Book a pilot with Replay - see your legacy screen extracted live during the call.

Ready to try Replay?

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

Launch Replay Free