Skip to content

Creating Comprehensive RPG Documentation Using AWS AI Services

7 minute read
Content level: Intermediate
1

Context: Organizations face disappearing RPG expertise as developers retire, leaving critical IBM i systems undocumented. Purpose: Demonstrate how AWS AI services with MCP can automatically generate accurate RPG documentation by grounding AI with authoritative learning materials, preserving institutional knowledge and enabling safe modernization before expertise vanishes completely.

This article demonstrates how to automatically generate comprehensive documentation for legacy RPG applications using AWS AI services combined with authoritative knowledge bases, enabling organizations to preserve institutional knowledge before experienced developers retire.

The Challenge

Organizations running IBM-i systems encounter a significant challenge as their RPG applications contain decades of embedded business logic while documentation remains outdated or completely absent.The retirement of experienced RPG developers compounds this problem by causing institutional knowledge to vanish, which makes system maintenance and modernization efforts increasingly complex and risky.

The Solution: AWS AI Services for Documentation Generation

AWS AI services can automatically analyze RPG source code and generate comprehensive documentation that captures business logic, data flows, and program relationships

SolutionArchitecture

The architecture above demonstrates the complete workflow for RPG documentation generation and modernization. In this diagram, Kiro can be replaced with any generative AI solution such as Amazon Q Developer, Amazon Bedrock, or partner AI solutions. The process flows as follows:

  • Source Repository (S3 Bucket) contains the original RPG code

  • AWS Transform analyzes the code and generates documentation and business rules for the supported technology like COBOL

  • AI Processing (Kiro/Amazon Q Developer/Bedrock) combines the documentation with Language Knowledge Base through MCP (Model Context Protocol)

  • Prompt Engineering guides the AI to generate contextual documentation

  • Code Output produces both comprehensive documentation and modernized code in target languages like Python or Java

  • Target System receives the transformed, modern applications

Key Architecture Benefits: Flexible AI Integration: This solution provides flexible AI integration by working seamlessly with multiple AWS AI services including Amazon Q Developer, AWS Kiro, and Amazon Bedrock. The Model Context Protocol (MCP) ensures that AI services have direct access to authoritative RPG learning materials, enabling better code interpretation.

The documentation generated through this process creates a comprehensive knowledge base that preserves institutional knowledge about the application.

The Critical Role of Learning Manuals in Knowledge Base

Why Learning Manuals Matter

The accuracy of AWS AI generated documentation depends heavily on the system's understanding of RPG language rules and syntax. Without proper reference materials, the services may misinterpret RPG specific constructs, generate incorrect explanations of business logic, or miss important language nuances that affect program behavior.

By including official RPG learning manuals in the knowledge base, AWS AI services can reference actual language rules instead of making assumptions. This enables them to understand RPG syntax correctly, including indicators, data structures, and file operations. The authoritative sources minimize hallucinations by providing factual documentation to reference, which creates trustworthy documentation because the AI comprehends what the code actually does. Additionally, the services can interpret complex RPG patterns using established programming conventions, ensuring that the generated documentation reflects true program behavior rather than AI assumptions.

How It Works

The first step involves setting up a comprehensive knowledge base with learning manuals. see appendix 1 on how to utilize memory-bank mcp for this purpose. This includes IBM RPG Reference Manuals containing official language syntax and built in functions, RPG Programming Guides with best practices and coding patterns, ILE RPG Documentation covering modern RPG features and procedures, your organization's coding standards with internal conventions and naming rules, and existing documentation with business rule descriptions and process flows.

The second step focuses on AWS AI code analysis. You feed RPG source code to AWS AI services such as Amazon Q Developer, AWS Kiro, or Amazon Bedrock. The services then cross reference the code against learning manuals to understand syntax, validate interpretations against official RPG documentation, and generate documentation with accurate explanations grounded in actual language rules.

The final step produces accurate documentation output. AWS AI services create reliable documentation because they understand RPG correctly. This includes program summaries with accurate descriptions of each RPG program's purpose, business logic documentation providing correct explanations of calculations and decision logic, data flow diagrams that precisely map how data moves through the system, integration points that accurately identify program and file relationships, and change impact analysis offering reliable assessments based on proper code understanding.

Key Benefits of Reference Material-Grounded Approach

Enhanced Accuracy and Reliability - AWS AI services produce dependable documentation by understanding RPG syntax correctly through referencing official documentation. This approach reduces documentation errors caused by misinterpretation and ensures explanations align with actual RPG language behavior

Preserve Knowledge Correctly - The solution preserves knowledge correctly by capturing business logic accurately before RPG experts retire. It documents complex calculations with proper understanding of RPG operations and creates a trustworthy knowledge repository that developers can rely on for future reference

Accelerate Maintenance Safely - Organizations can accelerate maintenance safely because new developers receive accurate information about RPG programs. This reduces time spent correcting misunderstood legacy code and enables confident code changes based on reliable documentation.

Support Modernization Effectively - The approach supports modernization effectively by providing accurate requirements for rewriting applications. It correctly identifies which programs contain critical business logic and maps dependencies accurately using proper code understanding, ensuring successful transformation initiatives.

Getting Started

  • Gather RPG learning materials - Collect official IBM documentation and internal standards

  • Choose your AWS AI service based on your specific needs:

    • Amazon Q Developer for development-focused documentation

    • AWS Kiro for agentic IDE that enables spec driven development

    • Amazon Bedrock for custom documentation workflows

  • Build your knowledge base with authoritative RPG sources first. See appendix 1 for details.

  • Start with critical programs that need accurate documentation most urgently

  • Validate AWS AI output against your RPG expertise to ensure accuracy

  • Refine the knowledge base based on documentation quality feedback

Result

By grounding AWS AI services with authoritative RPG learning manuals, organizations can create comprehensive, dependable documentation that truly reflects their IBM-i systems. The AWS AI suite's understanding of actual RPG language rules ensures reliable documentation that developers can trust for maintenance and modernization decisions.

This approach transforms undocumented RPG code into well-documented, accurately understood business assets that support both current operations and future modernization efforts with confidence in the documentation's correctness.


Appendix :

  1. You can utilize this MCP server to provide memory and create langauge reference knowledgebase for your agentic solution : https://github.com/movibe/memory-bank-mcp/blob/main/README.md

Model Context Protocol (MCP) serves as the critical bridge between AWS AI services and authoritative RPG knowledge sources, enabling persistent, context-aware documentation generation. Organizations can implement MCP by deploying a memory bank server that stores IBM RPG reference manuals, programming guides, internal coding standards, and business documentation in a structured, searchable format. The integration process involves installing the MCP server using npm install @movibe/memory-bank-mcp or running it directly with npx @movibe/memory-bank-mcp, then configuring it to work alongside AWS AI services like Kiro, Amazon Q Developer, or Bedrock. Once established, the MCP server maintains persistent context across multiple documentation sessions, allowing AI services to reference previous analysis results, accumulated RPG knowledge, and established interpretation patterns when processing new code. This approach transforms static reference materials into dynamic, accessible knowledge that grounds AI responses in factual RPG syntax rules rather than assumptions, significantly reducing hallucinations and improving documentation accuracy. The MCP integration creates a feedback loop where each documentation session enriches the knowledge base, building institutional memory that preserves RPG expertise even as experienced developers retire, ultimately enabling more reliable and comprehensive legacy system documentation and modernization efforts.

  1. Kiro Agentic IDE and Spec Driven Development Kiro is an agentic IDE that revolutionizes software development through spec driven methodology, enabling developers to move seamlessly from prototype to production ready applications. Kiro's spec driven approach ensures that what developers build matches their exact requirements by first creating detailed specifications that serve as blueprints for code generation. The IDE automates repetitive development tasks including documentation creation, test generation, and code structure implementation, allowing developers to focus on higher level design decisions and business logic. Try kiro at https://kiro.dev/

  2. The same solution can be applied to generate documentation and code for other niche languages like Smalltalk etc. where you provide the learning manuals for the respective language to the knowledge base