rpg-migration-analyzer

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

RPG Migration Analyzer

RPG迁移分析工具

Analyzes legacy RPG programs (RPG III/IV/ILE) from AS/400 and IBM i systems for migration to modern Java applications, extracting business logic, data structures, file operations, and generating actionable migration strategies.
分析来自AS/400和IBM i系统的遗留RPG程序(RPG III/IV/ILE),以迁移至现代Java应用,提取业务逻辑、数据结构、文件操作并生成可执行的迁移策略。

Overview

概述

This skill provides comprehensive analysis and migration planning for RPG (Report Program Generator) applications. It extracts program specifications, converts RPG data types to Java equivalents, maps file operations to modern database access patterns, and generates implementation-ready Java code structures.
Key Migration Focus: RPG to Java with proper handling of packed decimals (BigDecimal), data structures (POJOs), file operations (JPA/JDBC), indicators (boolean variables), and business logic preservation.
该工具为RPG(Report Program Generator)应用提供全面的分析和迁移规划。它提取程序规范,将RPG数据类型转换为Java等效类型,将文件操作映射到现代数据库访问模式,并生成可直接用于实施的Java代码结构。
核心迁移重点:将RPG转换为Java,妥善处理压缩小数(BigDecimal)、数据结构(POJO)、文件操作(JPA/JDBC)、指示器(布尔变量)并保留业务逻辑。

When to Use This Skill

适用场景

Use this skill when:
  • Analyzing RPG source files (.rpg, .rpgle, .RPGLE) for modernization
  • Planning migration from AS/400 or IBM i systems to Java
  • Converting RPG data structures (D-specs) to Java classes
  • Mapping RPG file operations (F-specs) to database access patterns
  • Understanding RPG program dependencies and call chains
  • Generating Java code equivalents from RPG business logic
  • Estimating complexity and effort for RPG migration projects
  • Creating migration documentation and strategy reports
  • Modernizing legacy mainframe applications to microservices
  • User mentions: RPG analysis, AS/400 migration, IBM i modernization, Report Program Generator, packed decimal conversion
在以下场景中使用该工具:
  • 分析RPG源文件(.rpg、.rpgle、.RPGLE)以进行现代化改造
  • 规划从AS/400或IBM i系统到Java的迁移
  • 将RPG数据结构(D-specs)转换为Java类
  • 将RPG文件操作(F-specs)映射到数据库访问模式
  • 了解RPG程序依赖关系和调用链
  • 从RPG业务逻辑生成Java等效代码
  • 评估RPG迁移项目的复杂度和工作量
  • 创建迁移文档和策略报告
  • 将遗留大型机应用现代化为微服务
  • 用户提及以下内容时:RPG分析、AS/400迁移、IBM i现代化、Report Program Generator、压缩小数转换

Core Capabilities

核心能力

1. Program Analysis

1. 程序分析

Extract and analyze RPG program components:
  • Specification types: H-spec (header/control), F-spec (file definitions), D-spec (data definitions), C-spec (calculation/logic), P-spec (procedures)
  • Data structures: D-specs with nested structures, arrays (DIM), external references (EXTNAME), qualifiers (LIKEDS, QUALIFIED)
  • File definitions: Physical files, logical files, display files (WORKSTN), printer files
  • Business logic: Calculation specifications, control structures (IF/ELSE/DO/FOR), expressions (EVAL)
  • Indicators: Legacy indicators (*IN01-*IN99), built-in indicators (*INLR,*INOF)
  • Built-in functions: String functions (%SUBST, %TRIM, %SCAN), date functions (%DATE, %DAYS), math functions (%DEC, %INT), file status (%EOF, %FOUND, %ERROR)
  • Error handling: %ERROR, %STATUS, ON-ERROR blocks
提取并分析RPG程序组件:
  • 规范类型:H-spec(头部/控制)、F-spec(文件定义)、D-spec(数据定义)、C-spec(计算/逻辑)、P-spec(过程)
  • 数据结构:带嵌套结构的D-spec、数组(DIM)、外部引用(EXTNAME)、限定符(LIKEDS、QUALIFIED)
  • 文件定义:物理文件、逻辑文件、显示文件(WORKSTN)、打印文件
  • 业务逻辑:计算规范、控制结构(IF/ELSE/DO/FOR)、表达式(EVAL)
  • 指示器:遗留指示器(*IN01-*IN99)、内置指示器(*INLR、*INOF)
  • 内置函数:字符串函数(%SUBST、%TRIM、%SCAN)、日期函数(%DATE、%DAYS)、数学函数(%DEC、%INT)、文件状态(%EOF、%FOUND、%ERROR)
  • 错误处理:%ERROR、%STATUS、ON-ERROR块

2. Data Structure Mapping

2. 数据结构映射

Convert RPG data definitions to Java equivalents:
  • D-spec conversion: Data structure definitions to Java classes (POJOs)
  • Data type mapping:
    • Packed decimal (P) →
      BigDecimal
      (preserve precision)
    • Zoned decimal (S) →
      BigDecimal
      (decimal with sign)
    • Character (A) →
      String
    • Date (D) →
      LocalDate
    • Time (T) →
      LocalTime
    • Timestamp (Z) →
      LocalDateTime
    • Indicator (N) →
      boolean
    • Binary integer (I) →
      int
      or
      long
  • Arrays (DIM): Convert to Java
    List<T>
    or arrays
    T[]
  • Nested data structures: Convert LIKEDS to nested Java classes
  • External data structures (EXTNAME): Generate JPA entities from database table definitions
  • Initialization (INZ): Map to Java field initializers or constructors
将RPG数据定义转换为Java等效类型:
  • D-spec转换:将数据结构定义转换为Java类(POJO)
  • 数据类型映射
    • 压缩小数(P)→
      BigDecimal
      (保留精度)
    • 带符号小数(S)→
      BigDecimal
      (带符号小数)
    • 字符型(A)→
      String
    • 日期型(D)→
      LocalDate
    • 时间型(T)→
      LocalTime
    • 时间戳(Z)→
      LocalDateTime
    • 指示器(N)→
      boolean
    • 二进制整数(I)→
      int
      long
  • 数组(DIM):转换为Java
    List<T>
    或数组
    T[]
  • 嵌套数据结构:将LIKEDS转换为嵌套Java类
  • 外部数据结构(EXTNAME):从数据库表定义生成JPA实体
  • 初始化(INZ):映射到Java字段初始化器或构造函数

3. File Operations

3. 文件操作

Parse and convert RPG file I/O to modern database access:
  • File types: Physical files (DISK), logical files (keyed access), display files (WORKSTN), printer files (PRINTER)
  • Access methods: Sequential (full read), keyed (direct access by key), arrival sequence
  • I/O operations:
    • READ/READE → JPA query methods, JDBC ResultSet iteration
    • WRITE → JPA persist(), JDBC INSERT
    • UPDATE → JPA merge(), JDBC UPDATE
    • DELETE → JPA remove(), JDBC DELETE
    • CHAIN → JPA findById(), Optional pattern
    • SETLL/READE loop → JPA findBy...() queries with ordering
  • File status: %EOF (end of file), %FOUND (record found), %ERROR (I/O error) → Java exceptions or Optional
  • Transaction boundaries: Identify commit boundaries (COMMIT operation code)
解析并将RPG文件I/O转换为现代数据库访问方式:
  • 文件类型:物理文件(DISK)、逻辑文件(键控访问)、显示文件(WORKSTN)、打印文件(PRINTER)
  • 访问方式:顺序(全量读取)、键控(按键直接访问)、到达序列
  • I/O操作
    • READ/READE → JPA查询方法、JDBC ResultSet迭代
    • WRITE → JPA persist()、JDBC INSERT
    • UPDATE → JPA merge()、JDBC UPDATE
    • DELETE → JPA remove()、JDBC DELETE
    • CHAIN → JPA findById()、Optional模式
    • SETLL/READE循环 → 带排序的JPA findBy...()查询
  • 文件状态:%EOF(文件结束)、%FOUND(找到记录)、%ERROR(I/O错误)→ Java异常或Optional
  • 事务边界:识别提交边界(COMMIT操作码)

4. Java Migration Strategy

4. Java迁移策略

Generate modern Java implementation patterns:
  • POJOs: Plain Old Java Objects from D-spec data structures
  • JPA Entities: @Entity annotations for database tables (from EXTNAME files)
  • Repository pattern: Spring Data JPA repositories for file operations
  • Service methods: Business logic from procedures and subroutines
  • Bean Validation: @NotNull, @Size, @DecimalMin/Max from RPG field validations
  • Exception handling: Convert %ERROR patterns to try-catch blocks with custom exceptions
  • Collections: Java Collections API (List, Map, Set) from RPG arrays and data structures
  • DTOs: Data Transfer Objects for service boundaries
  • Transaction management: @Transactional annotations for commit boundaries
生成现代Java实现模式:
  • POJO:从D-spec数据结构生成普通Java对象
  • JPA实体:为数据库表添加@Entity注解(来自EXTNAME文件)
  • 仓库模式:用于文件操作的Spring Data JPA仓库
  • 服务方法:来自过程和子例程的业务逻辑
  • Bean验证:从RPG字段验证生成@NotNull、@Size、@DecimalMin/Max注解
  • 异常处理:将%ERROR模式转换为带自定义异常的try-catch块
  • 集合:用Java集合API(List、Map、Set)替代RPG数组和数据结构
  • DTO:用于服务边界的数据传输对象
  • 事务管理:为提交边界添加@Transactional注解

5. Dependency Analysis

5. 依赖分析

Map program relationships and external dependencies:
  • Program calls: CALLB (bound procedure calls), CALLP (prototyped procedure calls)
  • Service programs: BNDDIR (binding directories), *SRVPGM objects
  • File dependencies: All physical/logical files accessed by the program
  • Database tables: DB2 for i tables referenced (EXTNAME)
  • /COPY members: Include files, copy source members, prototypes
  • Call chains: Identify calling programs and called programs
  • Shared data areas: *DTAARA usage
  • Message queues: QMHSNDPM (send program message)
映射程序关系和外部依赖:
  • 程序调用:CALLB(绑定过程调用)、CALLP(原型化过程调用)
  • 服务程序:BNDDIR(绑定目录)、*SRVPGM对象
  • 文件依赖:程序访问的所有物理/逻辑文件
  • 数据库表:引用的DB2 for i表(EXTNAME)
  • /COPY成员:包含文件、复制源成员、原型
  • 调用链:识别调用程序和被调用程序
  • 共享数据区域:*DTAARA的使用
  • 消息队列:QMHSNDPM(发送程序消息)

Instructions

操作步骤

Follow these steps to analyze and migrate RPG programs to Java:
按照以下步骤分析并将RPG程序迁移到Java:

Step 1: Locate RPG Source Files

步骤1:定位RPG源文件

Find RPG source files (.rpg, .rpgle, .RPGLE extensions for RPG III/IV/ILE free-format).
bash
find . -name "*.rpg" -o -name "*.rpgle" -o -name "*.RPGLE"
查找RPG源文件(RPG III/IV/ILE自由格式的.rpg、.rpgle、.RPGLE扩展名)。
bash
find . -name "*.rpg" -o -name "*.rpgle" -o -name "*.RPGLE"

Step 2: Analyze Program Structure

步骤2:分析程序结构

Extract specifications (H, F, D, C, P), data structures, file definitions, procedures, and dependencies.
Automation: Run
scripts/extract-structure.py
for automated extraction.
提取规范(H、F、D、C、P)、数据结构、文件定义、过程和依赖关系。
自动化:运行
scripts/extract-structure.py
进行自动提取。

Step 3: Map Data Types

步骤3:映射数据类型

Convert RPG to Java types - CRITICAL: Always use
BigDecimal
for packed/zoned decimals (never float/double).
RPG TypeJava TypeKey Notes
nP m
(packed)
BigDecimal
MUST preserve precision
nS m
(zoned)
BigDecimal
Decimal with sign
A
(char)
String
Character data
D/T/Z
(date/time)
LocalDate/LocalTime/LocalDateTime
Date fields
N
(indicator)
boolean
True/False flags
I
(integer)
int
or
long
Binary integer
DIM(n)
(array)
List<T>
or
T[]
Arrays
将RPG类型转换为Java类型 - 关键:始终使用
BigDecimal
处理压缩/带符号小数(绝不要用float/double)。
RPG类型Java类型关键说明
nP m
(压缩小数)
BigDecimal
必须保留精度
nS m
(带符号小数)
BigDecimal
带符号小数
A
(字符型)
String
字符数据
D/T/Z
(日期/时间)
LocalDate/LocalTime/LocalDateTime
日期字段
N
(指示器)
boolean
真/假标志
I
(整数)
int
long
二进制整数
DIM(n)
(数组)
List<T>
T[]
数组

Step 4: Convert Code Patterns

步骤4:转换代码模式

Transform RPG operations to Java - key conversions:
  • Calculations: EVAL expressions → BigDecimal arithmetic methods
  • File I/O: CHAIN →
    findById()
    with Optional, READ → query methods
  • Arrays: Adjust 1-based (RPG) to 0-based (Java) indexing
  • Strings: %SUBST(1-based) → substring(0-based)
  • Indicators: *IN01 → named boolean variables
See pseudocode-rpg-rules.md for comprehensive conversion patterns.
将RPG操作转换为Java - 关键转换:
  • 计算:EVAL表达式 → BigDecimal算术方法
  • 文件I/O:CHAIN → 带Optional的
    findById()
    、READ → 查询方法
  • 数组:将RPG的1-based索引调整为Java的0-based索引
  • 字符串:%SUBST(1-based) → substring(0-based)
  • 指示器:*IN01 → 具名布尔变量
查看Pseudocode-rpg-rules.md获取完整的转换模式。

Step 5: Generate Java Implementation

步骤5:生成Java实现

Create:
  1. POJOs from D-spec data structures (
    scripts/generate-java-classes.py
    )
  2. JPA entities for database tables
  3. Repository interfaces (Spring Data JPA)
  4. Service methods for business logic
  5. Exception handling and validation
创建以下内容:
  1. 从D-spec数据结构生成POJO(
    scripts/generate-java-classes.py
  2. 数据库表的JPA实体
  3. 仓库接口(Spring Data JPA)
  4. 业务逻辑的服务方法
  5. 异常处理和验证

Step 6: Analyze Dependencies

步骤6:分析依赖关系

Map program calls (CALLB/CALLP), file dependencies, /COPY members, service programs.
Automation: Run
scripts/analyze-dependencies.sh
or
.ps1
映射程序调用(CALLB/CALLP)、文件依赖、/COPY成员、服务程序。
自动化:运行
scripts/analyze-dependencies.sh
.ps1

Step 7: Create Migration Report

步骤7:创建迁移报告

Generate documentation with program overview, dependencies, data mappings, Java design, and complexity estimate.
Template: Use
assets/migration-report-template.md
生成包含程序概述、依赖关系、数据映射、Java设计和复杂度评估的文档。
模板:使用
assets/migration-report-template.md

Step 8: Validate and Test

步骤8:验证和测试

Verify: BigDecimal usage, index adjustments, transaction boundaries, error handling, unit tests with AS/400 data samples.
验证:BigDecimal的使用、索引调整、事务边界、错误处理、使用AS/400数据样本进行单元测试。

Quick Reference

快速参考

Critical Migration Rules

关键迁移规则

  1. ALWAYS use BigDecimal for RPG packed (P) and zoned (S) decimals - never float/double
  2. Adjust indexing: RPG uses 1-based arrays/strings, Java uses 0-based
  3. Replace indicators: Convert *IN01-*IN99 to descriptive boolean variables
  4. File operations: CHAIN → findById(), READ → query methods with Optional
  5. String functions: %SUBST(1:10) → substring(0, 10) - adjust positions
  6. Date operations: RPG date functions → LocalDate/LocalTime API
  7. Transactions: Identify COMMIT operations → @Transactional annotations
  8. Error handling: %ERROR/%STATUS → try-catch with custom exceptions
  1. 始终使用BigDecimal处理RPG压缩(P)和带符号(S)小数 - 绝不要用float/double
  2. 调整索引:RPG使用1-based数组/字符串,Java使用0-based
  3. 替换指示器:将*IN01-*IN99转换为描述性布尔变量
  4. 文件操作:CHAIN → findById()、READ → 带Optional的查询方法
  5. 字符串函数:%SUBST(1:10) → substring(0, 10) - 调整位置
  6. 日期操作:RPG日期函数 → LocalDate/LocalTime API
  7. 事务:识别COMMIT操作 → @Transactional注解
  8. 错误处理:%ERROR/%STATUS → 带自定义异常的try-catch

Example: Data Structure to Java Class

示例:数据结构转Java类

RPG D-spec:
rpg
D Employee   DS
D   EmpId             6  0
D   EmpName          30  A
D   Salary           63  2P
Java POJO:
java
public class Employee {
    private int empId;
    private String empName;
    private BigDecimal salary;  // 6 digits, 2 decimals
    // getters/setters
}
RPG D-spec:
rpg
D Employee   DS
D   EmpId             6  0
D   EmpName          30  A
D   Salary           63  2P
Java POJO:
java
public class Employee {
    private int empId;
    private String empName;
    private BigDecimal salary;  // 6位数字,2位小数
    // getters/setters
}

Example: File Operation Conversion

示例:文件操作转换

RPG CHAIN:
rpg
C     custId  CHAIN  CUSTFILE
C             IF     %FOUND(CUSTFILE)
Java with JPA:
java
customerRepository.findById(custId).ifPresent(customer -> {
    // process customer
});
java
// Service usage
public class CustomerService {
    @Autowired
    private CustomerRepository customerRepository;

    public Optional<Customer> findCustomer(Integer custId) {
        return customerRepository.findById(custId);
    }
}
RPG CHAIN:
rpg
C     custId  CHAIN  CUSTFILE
C             IF     %FOUND(CUSTFILE)
Java(JPA):
java
customerRepository.findById(custId).ifPresent(customer -> {
    // 处理客户
});
java
// 服务用法
public class CustomerService {
    @Autowired
    private CustomerRepository customerRepository;

    public Optional<Customer> findCustomer(Integer custId) {
        return customerRepository.findById(custId);
    }
}

Edge Cases

边缘情况

Case 1: Packed Decimal Precision

情况1:压缩小数精度

Problem: Using double/float causes precision errors. Solution: Always use
BigDecimal
from String literals:
new BigDecimal("123.45")
问题:使用double/float会导致精度错误。解决方案:始终从字符串字面量创建
BigDecimal
new BigDecimal("123.45")

Case 2: Array Index Shift

情况2:数组索引偏移

Problem: RPG 1-based, Java 0-based. Solution: Adjust all array/string index references. Test thoroughly.
问题:RPG是1-based,Java是0-based。解决方案:调整所有数组/字符串索引引用,彻底测试。

Case 3: External Data Structures

情况3:外部数据结构

Problem: EXTNAME without DDL source. Solution: Use DSPFFD command, query DB2 SYSTABLES/SYSCOLUMNS, or create entities from runtime data.
问题:没有DDL源的EXTNAME。解决方案:使用DSPFFD命令、查询DB2 SYSTABLES/SYSCOLUMNS,或从运行时数据创建实体。

Case 4: Legacy Indicators

情况4:遗留指示器

Problem: *IN01-*IN99 for control flow. Solution: Replace with descriptive booleans:
boolean invalidAmount = false;
问题:用*IN01-*IN99控制流程。解决方案:替换为描述性布尔变量:
boolean invalidAmount = false;

Case 5: Date Century Handling

情况5:日期世纪处理

Problem: 2-digit years (Y2K). Solution: Use 4-digit LocalDate, apply century window logic, document assumptions.
问题:2位年份(Y2K)。解决方案:使用4位LocalDate,应用世纪窗口逻辑,记录假设。

Guidelines

指南

  1. BigDecimal mandatory: Never float/double for packed/zoned decimals
  2. Named booleans: Replace *IN01-99 with descriptive names
  3. Database access: Map file I/O to JPA/JDBC operations
  4. JPA entities: Create from EXTNAME physical file definitions
  5. Exception handling: Convert %ERROR/%FOUND to exceptions/Optional
  6. Test with AS/400 data: Validate with actual legacy system data
  7. Transactions: Identify COMMIT operations → @Transactional
  8. Document rules: Extract and document implicit business logic
  9. Character encoding: Verify EBCDIC → Unicode conversions
  10. Batch processing: Convert batch jobs to Spring Batch framework
  1. 强制使用BigDecimal:绝不要用float/double处理压缩/带符号小数
  2. 具名布尔变量:用描述性名称替换*IN01-99
  3. 数据库访问:将文件I/O映射到JPA/JDBC操作
  4. JPA实体:从EXTNAME物理文件定义创建
  5. 异常处理:将%ERROR/%FOUND转换为异常/Optional
  6. 用AS/400数据测试:用实际遗留系统数据验证
  7. 事务:识别COMMIT操作 → 添加@Transactional
  8. 记录规则:提取并记录隐含的业务逻辑
  9. 字符编码:验证EBCDIC → Unicode转换
  10. 批处理:将批处理作业转换为Spring Batch框架

Error Handling

错误处理

Type 1: File I/O Errors

类型1:文件I/O错误

Detection: %ERROR or %STATUS checks. Handling: Use try-catch with custom exceptions (
CustomerNotFoundException
,
DataAccessException
)
检测:%ERROR或%STATUS检查。处理:使用带自定义异常的try-catch(
CustomerNotFoundException
DataAccessException

Type 2: Arithmetic Overflow

类型2:算术溢出

Detection: Insufficient field size. Handling: BigDecimal with appropriate scale/precision, catch
ArithmeticException
检测:字段大小不足。处理:使用带适当刻度/精度的BigDecimal,捕获
ArithmeticException

Type 3: Missing Dependencies

类型3:缺失依赖

Detection: Missing /COPY members. Handling: Track all includes, create shared interfaces, use Maven/Gradle dependencies
检测:缺失/COPY成员。处理:跟踪所有包含项,创建共享接口,使用Maven/Gradle依赖

Additional Resources

附加资源

See detailed documentation in the
references/
directory:
查看
references/
目录中的详细文档:

RPG Translation Rules (Organized by Topic)

RPG翻译规则(按主题分类)

The RPG translation rules are organized into focused, topic-specific files for easier navigation:
  • pseudocode-rpg-rules.md - Master index with quick start guide and file navigation
  • pseudocode-rpg-core-rules.md - Foundation: specs, data types, basic operations, file I/O
  • pseudocode-rpg-functions.md - Built-in functions (BIFs): string, date/time, math, array functions
  • pseudocode-rpg-data-structures.md - Data structure patterns: QUALIFIED, LIKEDS, OVERLAY, I/O specs
  • pseudocode-rpg-patterns.md - Common idioms, translation patterns, pitfalls, critical rules
  • pseudocode-rpg-advanced.md - ILE RPG, embedded SQL, web services, IFS, XML/JSON, threading
  • pseudocode-rpg-migration-guide.md - Migration workflow, best practices, refactoring strategies
RPG翻译规则按主题分类,便于导航:
  • pseudocode-rpg-rules.md - 主索引,包含快速入门指南和文件导航
  • pseudocode-rpg-core-rules.md - 基础:规范、数据类型、基本操作、文件I/O
  • pseudocode-rpg-functions.md - 内置函数(BIF):字符串、日期/时间、数学、数组函数
  • pseudocode-rpg-data-structures.md - 数据结构模式:QUALIFIED、LIKEDS、OVERLAY、I/O规范
  • pseudocode-rpg-patterns.md - 常见 idiom、翻译模式、陷阱、关键规则
  • pseudocode-rpg-advanced.md - ILE RPG、嵌入式SQL、Web服务、IFS、XML/JSON、线程
  • pseudocode-rpg-migration-guide.md - 迁移工作流、最佳实践、重构策略

Other Reference Documentation

其他参考文档

  • pseudocode-common-rules.md - General pseudocode syntax and conventions
  • testing-strategy.md - Testing approach for RPG to Java migration validation
  • transaction-handling.md - AS/400 transaction patterns to Java transaction management
  • performance-patterns.md - Performance optimization patterns for migrated code
  • messaging-integration.md - Message queue and integration patterns for IBM i systems
  • pseudocode-common-rules.md - 通用伪代码语法和约定
  • testing-strategy.md - RPG到Java迁移验证的测试方法
  • transaction-handling.md - AS/400事务模式到Java事务管理
  • performance-patterns.md - 迁移代码的性能优化模式
  • messaging-integration.md - IBM i系统的消息队列和集成模式

Scripts

脚本

Python and shell scripts for automated analysis in
scripts/
:
  • analyze-dependencies.sh/ps1
    - Scans RPG source for CALLB, CALLP, /COPY; generates dependency graph
  • extract-structure.py
    - Parses RPG specs (H, F, D, C, P); outputs structured JSON
  • generate-java-classes.py
    - Creates Java POJOs from RPG data structures with proper types
  • estimate-complexity.py
    - Calculates migration complexity score and effort estimate
scripts/
目录中的Python和Shell脚本用于自动化分析:
  • analyze-dependencies.sh/ps1
    - 扫描RPG源文件中的CALLB、CALLP、/COPY;生成依赖图
  • extract-structure.py
    - 解析RPG规范(H、F、D、C、P);输出结构化JSON
  • generate-java-classes.py
    - 从RPG数据结构创建带正确类型的Java POJO
  • estimate-complexity.py
    - 计算迁移复杂度得分和工作量评估

Templates

模板

  • migration-report-template.md - Standard format for migration analysis reports
  • java-class-template.java - Template for generated Java classes
analyze-dependencies.sh / .ps1
  • Scans RPG source files for CALLB, CALLP, /COPY references
  • Generates dependency graph in JSON format
  • Identifies circular dependencies
Usage:
bash
./scripts/analyze-dependencies.sh /path/to/rpg/source
extract-structure.py
  • Extracts program structure (H/F/D/C/P specs)
  • Lists all variables, data structures, files
  • Identifies subroutines and procedures
  • Outputs JSON structure file
Usage:
bash
python scripts/extract-structure.py PROGRAM.rpgle --output structure.json
generate-java-classes.py
  • Generates Java POJO classes from RPG data structures
  • Creates proper field types (BigDecimal for packed decimals)
  • Adds getters, setters, constructors
  • Generates Bean Validation annotations
Usage:
bash
python scripts/generate-java-classes.py structure.json --output-dir ./src/main/java
estimate-complexity.py
  • Calculates migration complexity score
  • Analyzes LOC, dependencies, file operations
  • Provides effort estimate (hours/days)
  • Generates priority ranking
Usage:
bash
python scripts/estimate-complexity.py structure.json --report complexity-report.md
  • migration-report-template.md - 迁移分析报告的标准格式
  • java-class-template.java - 生成Java类的模板
analyze-dependencies.sh / .ps1
  • 扫描RPG源文件中的CALLB、CALLP、/COPY引用
  • 生成JSON格式的依赖图
  • 识别循环依赖
用法:
bash
./scripts/analyze-dependencies.sh /path/to/rpg/source
extract-structure.py
  • 提取程序结构(H/F/D/C/P规范)
  • 列出所有变量、数据结构、文件
  • 识别子例程和过程
  • 输出JSON结构文件
用法:
bash
python scripts/extract-structure.py PROGRAM.rpgle --output structure.json
generate-java-classes.py
  • 从RPG数据结构生成Java POJO类
  • 创建正确的字段类型(压缩小数用BigDecimal)
  • 添加getter、setter、构造函数
  • 生成Bean验证注解
用法:
bash
python scripts/generate-java-classes.py structure.json --output-dir ./src/main/java
estimate-complexity.py
  • 计算迁移复杂度得分
  • 分析代码行数、依赖关系、文件操作
  • 提供工作量评估(小时/天)
  • 生成优先级排名
用法:
bash
python scripts/estimate-complexity.py structure.json --report complexity-report.md

Templates

模板

Use the migration report template for consistent documentation:
  • migration-report-template.md - Standard format for migration analysis reports
  • java-class-template.java - Template for generated Java classes with proper structure
使用迁移报告模板确保文档一致性:
  • migration-report-template.md - 迁移分析报告的标准格式
  • java-class-template.java - 带正确结构的生成Java类模板

Integration with Development Tools

与开发工具的集成

This skill integrates with various development and analysis tools:
该工具可与多种开发和分析工具集成:

IBM i / AS/400 Tools

IBM i / AS/400工具

  • Source Entry Utility (SEU): Extract source code from AS/400
  • Programming Development Manager (PDM): Access member lists and source files
  • WRKMBRPDM: Work with source members
  • DSPFFD: Display file field descriptions for database structure analysis
  • DSPPGMREF: Display program references and dependencies
  • Source Entry Utility (SEU):从AS/400提取源代码
  • Programming Development Manager (PDM):访问成员列表和源文件
  • WRKMBRPDM:管理源成员
  • DSPFFD:显示文件字段描述以进行数据库结构分析
  • DSPPGMREF:显示程序引用和依赖关系

Database Tools

数据库工具

  • DB2 for i: Query system catalogs (SYSTABLES, SYSCOLUMNS) for metadata
  • IBM Data Studio: Visual database design and SQL development
  • DBeaver: Universal database tool with DB2 support
  • DB2 for i:查询系统目录(SYSTABLES、SYSCOLUMNS)获取元数据
  • IBM Data Studio:可视化数据库设计和SQL开发
  • DBeaver:支持DB2的通用数据库工具

Modern Development Environment

现代开发环境

  • IntelliJ IDEA: Java development with Spring Boot support
  • Eclipse: Java IDE with JPA tooling
  • VS Code: Lightweight editor with Java extensions
  • Git: Version control for both legacy source and new Java code
  • IntelliJ IDEA:带Spring Boot支持的Java开发工具
  • Eclipse:带JPA工具的Java IDE
  • VS Code:带Java扩展的轻量级编辑器
  • Git:遗留源代码和新Java代码的版本控制

Migration Support Tools

迁移支持工具

  • Spring Initializr: Bootstrap Spring Boot projects
  • JPA Buddy: IntelliJ plugin for JPA entity generation
  • Liquibase/Flyway: Database migration version control
  • Maven/Gradle: Build automation and dependency management
  • Spring Initializr:快速搭建Spring Boot项目
  • JPA Buddy:用于JPA实体生成的IntelliJ插件
  • Liquibase/Flyway:数据库迁移版本控制
  • Maven/Gradle:构建自动化和依赖管理

Testing and Validation

测试与验证

  • JUnit 5: Unit testing framework
  • Spring Boot Test: Integration testing support
  • Mockito: Mocking framework for unit tests
  • TestContainers: Database integration testing with containers
  • JUnit 5:单元测试框架
  • Spring Boot Test:集成测试支持
  • Mockito:单元测试的模拟框架
  • TestContainers:用容器进行数据库集成测试