How to Use Claude to Modernize RPG on IBM i (OS/400 V7R3)
Author: Russ Afton/Co-Pilot
Topic: AI-assisted modernization of legacy RPG (Report Program Generator) applications
Many organizations continue to rely on IBM i (formerly AS/400) systems running OS/400 V7R3 and mission-critical applications written in RPG (Report Program Generator). While RPG remains powerful and stable, much of the existing codebase—especially fixed-format RPG III or early RPG IV—can be difficult to maintain, extend, and integrate with modern systems.
But, with the emergence of generative AI tools such as Claude and IBM i, developers now have a powerful assistant to help refactor, modernize, and even partially rewrite RPG applications. Let’s explore how to effectively use Claude to “recode” RPG programs into modern free-form syntax while preserving business logic.
First, Why Modernize?
Before diving into Claude, it’s important to understand the goals of modernization:
- Convert fixed-format RPG to free-form RPG IV
- Improve readability and maintainability
- Reduce onboarding time for new developers
- Enable integration with modern APIs (REST, JSON, SQL)
- Prepare workloads for hybrid/cloud environments
Legacy OS/400 V7R3 environments often contain code written decades ago. While stable, such code can:
- Use outdated op-codes (MOVE, Z-ADD, etc.)
- Depend on indicators rather than structured logic
- Lack modular design
- Be difficult to debug or extend
Second, Why Claude?
Claude is especially well-suited for legacy modernization because it:
- Handles large code blocks better than most AI tools
- Understands older programming paradigms like RPG III
- Can translate fixed-format RPG to modern free-form syntax
- Provides explanations of legacy logic
- Assists in step-by-step refactoring, not just full rewrites.
Rather than replace developers, Claude accelerates their work by acting as:
- A code translator
- A documentation assistant
- A modernization advisor
Recommended Workflow for Recoding using Claude
1. Start with Analysis
Begin by feeding a portion of your RPG code into Claude and ask it to explain the logic. Below is an example of what this might look like:
Prompt:
“Explain this RPG program written for IBM i OS/400 V7R3. Identify its purpose, inputs, outputs, and key logic.”
Note: A well-written prompt helps:
- Validate that the AI understands the code
- Reveal hidden dependencies
- Document business rules before rewriting
2. Convert Fixed-Format to Free-Form RPG
Once understood, ask Claude to modernize the syntax.
Prompt:
“Convert this fixed-format RPG code into modern free-form RPG IV. Preserve logic but improve readability and structure.”
Sample Result from Claude:
Old Fixed-Format RPG:
C *ENTRY PLIST
C PARM CUSTNO
C CUSTNO CHAIN CUSTFILE 50
C *IN50 IFEQ *OFF
C MOVE NAME RESULT
C ENDIF
C SETON LR
Claude-Generated Free-Form:
dcl-pi *n;
custNo char(10);
end-pi;
chain custNo CUSTFILE;
if not %found(CUSTFILE);
result = name;
endif;
*inlr = *on;
3. Replace Indicators with Structured Logic
Older RPG relies heavily on numeric indicators (*INxx). Claude can help convert these into
readable conditions.
Prompt:
“Refactor this code to eliminate indicators and use structured IF/ELSE logic.”
4. Introduce Modern Features
Claude can suggest improvements beyond simple translation:
- Replace native I/O with embedded SQL
- Use data structures instead of flat fields
- Introduce procedures and service programs
- Add error handling
Prompt:
“Rewrite this program using embedded SQL instead of CHAIN and READ opcodes.”
5. Break Monolithic Code into Modules
Many RPG programs are large and monolithic. Claude can help modularize:
Prompt:
“Refactor this RPG program into reusable procedures and recommend a service program structure”
6. Document the Modernized Code
Claude excels at documentation:
Prompt:
“Add comments and documentation explaining each section of this modern RPG code.”
This step is especially useful for:
- Knowledge transfer
- Compliance
- Future maintenance
Tips For Using Claude
Use Small, Focused Chunks
Avoid dumping entire 10,000-line programs. Instead:
- Work in sections (200–500 lines)
- Validate output before proceeding
Be Explicit About IBM i Context
Always specify:
- OS version: OS/400 V7R3
- RPG type: RPG III, RPG IV, fixed-format
Iterate Instead of One-Shot Conversion
A better approach is:
- Explain
- Convert
- Refactor
- Optimize
Validate Output on IBM i
Claude-generated code must be tested:
- Compile on IBM i
- Validate file definitions (DDS vs SQL tables)
- Test edge cases
- Review performance
Limitations and Considerations
While powerful, Claude is not perfect:
- May misinterpret rare op-codes
- Might assume modern defaults incompatible with V7R3
- Cannot access external file definitions (DDS) unless provided
- Requires human validation for business-critical logic
Therefore, always treat AI output as a starting point, not a final product.
Real-World Use Cases
Organizations are already using AI-assisted RPG modernization for:
- Converting green-screen applications to modern interfaces
- Preparing systems for API enablement
- Reducing technical debt
- Accelerating onboarding of new developers
Claude represents a significant advancement for IBM i developers working with legacy RPG code. By combining deep language understanding with flexible prompting, it enables teams to:
- Modernize faster
- Improve code quality
- Preserve critical business logic
For organizations running OS/400 V7R3, Claude provides a practical bridge between decades-old systems and modern development practices—without requiring a complete rewrite from scratch.
Suggested Next Steps
- Pilot Claude on a non-critical RPG program
- Establish prompt standards within your team
- Create a review and testing workflow
- Gradually expand modernization efforts
Arbor Solutions is here and ready to help you with your next project! Contact us today!