RPG Programming on IBM i, Explained One Program at a Time

  • October 10, 2026
  • Ty Woods
  • 10 min read

One of your developers opens an RPG program that someone wrote before they joined the team. Near the top, a single line pulls in a copy member from another library. Part of the program’s logic now lives in a member that the developer has not opened yet.

A copy member line like that is a normal part of RPG programming on IBM i. Before anyone changes the program, someone on your team has to find every piece it pulls in and say what each piece does.

Your goal is a written description of every program in the library, ready before the first change goes in. That work starts with one program and the pieces it pulls in.

What RPG programming is

IBM introduced RPG in 1959 for the IBM 1401, and the language has long used a program cycle and column-oriented syntax.

In the program cycle, a programmer writes code that processes one record. The cycle runs that code against every record of a file and handles the control flow on its own. A reader who looks for a loop over the records finds none, because the cycle supplies it.

Column-oriented syntax is the second idea. In fixed-format source, the column where an entry starts is part of what the entry means. For example, the specification letter goes in column 6 and the data type goes in column 40. Two lines that look alike can mean different things when an entry starts one column later.

Indicators are the third idea in RPG programming. An indicator is a logical variable numbered from 01 to 99, and a line of code acts or does nothing depending on whether its indicator is on or off. To know what such a line does for a given record, you need to know the state of its indicator at that moment.

RPG is best known as the primary programming language of IBM’s midrange product line, including the IBM i operating system.

What one RPG program contains

A trace of one program starts with its specifications. File specifications list the files a program writes to, reads from or updates. Calculation specifications contain the executable instructions, and those instructions are the program’s logic.

A program does not always describe its own records. On IBM i, a team can define files and reports outside the program in DDS, and that outside definition mostly removes the need to hand-code input and output specifications. The layout of each record then comes from the DDS, and a trace of the program has to include it.

Copy members pull source from other members into a program at compile time. A /COPY line can pull the program’s prototype in from a separate source file, and other programs use that prototype to call the program. Our post on how copy members hide dependencies covers that part of the trace in more detail.

A program can also call other programs. A called program can have its own files and copy members, and the trace continues into each one. A program can contain embedded SQL statements as well, and the SQL precompiler turns them into RPG statements at compile time. A trace that skips those statements leaves out part of what the program does.

The file specifications, the copy members, the calls and the embedded SQL together show what one program depends on. The reach of a change is the opposite question. When someone changes a field, the change reaches every program that uses the field and every report that prints it. Only a trace across the other programs in the library can produce that list.

DSPPGMREF gives you a first view of one program on your own system, because it reports which files a program references. Run DSPPGMREF against a program that your team changes often. The command works at the file level, and it captures the references when the program compiles. A change to the source since that compile does not show in its list.

That check covers one program. A library can have hundreds of programs, and the same trace has to repeat for each of them before anyone can answer the reach question with confidence. We built AS/Forward to trace every program in a library.

How RPG changed from RPG II to fully free-format RPG IV

Five steps changed RPG programming after the first version of RPG. Each step added something that a program in your library can still have today.

Step When Machine or release What the step brought
RPG II About 1969 The System/3, and later the System/32, System/34 and System/36 Level breaks and matching records in the program cycle
RPG III 1979, when IBM introduced the System/38 The System/38 and its successor, the AS/400. RPG/400 is RPG III running on the AS/400 IF-ENDIF blocks and DO loops, along with subroutines
RPG IV, also called ILE RPG 1994 OS/400 V3R2 A greater variety of expressions in the calculations. The name RPG stopped standing for Report Program Generator
Free-format calculations 2001 OS/400 V5R1 Developers could write the calculations in free-format, outside the columns
Fully free-format RPG IV November 2013 IBM i 7.1 TR7 The /FREE and /END-FREE lines were no longer needed, and free-format reached the rest of the program

RPG keeps a great deal of backward compatibility, and older programs still compile and run. Most RPG programmers stopped using the cycle with RPG III and control the flow with loops. IBM still supports the cycle, and a program from the RPG II step can still depend on it.

Why your library mixes fixed-format and free-format code

A source library often contains fixed-format RPG III beside free-format RPG IV, with DDS-defined files, display files, printer files and copy members threaded through it. A program from the RPG III step uses fixed-format columns throughout. Within RPG IV, a member can still use fixed-format calculations, because free-format arrived in two later steps.

A single member can mix both styles too. Before the fully free-format step, free-format covered the calculation specifications only. A member from that time can have free-format calculations between /FREE and /END-FREE lines, with fixed-format specifications around them.

Is RPG the same as RPGLE? No, RPGLE is the source type of an ILE RPG member, and ILE RPG is another name for RPG IV. A new member in QRPGLESRC, the default source file for ILE RPG, gets the source type RPGLE. CRTBNDRPG compiles ILE RPG from QRPGLESRC by default. CRTRPGPGM starts the RPG/400 compiler, and its default source file is QRPGSRC.

The source type is worth a look on your own system, because only an RPG IV member can contain free-format code. An RPGLE member can mix both styles, and an RPG/400 member uses fixed-format columns throughout. Check the source type of each member in QRPGSRC and QRPGLESRC.

When you want every program in one style, our page on fixed-format to free-format RPG explains how we clean up older code while it stays in RPG.

How a manager can understand RPG code without reading every line

A manager with no background in RPG programming still needs to know what each program does before approving a change. AS/Forward builds a program page for each program, and the work behind each page starts with the source.

AS/Forward reads all six RPG dialects through a proprietary ingestion layer, and it has one US patent pending. The structured read of the source comes first, and the language model works from that read. We don’t hand raw code to a language model and hope for the best.

From the ingested source, AS/Forward writes a plain-English description of every program. Each description says what the program reads and writes, and what its logic does. Each program page in AS/Forward pairs the source with four parts:

  • The plain-English description appears beside the source, and a developer can check one against the other.
  • The dependency edges connect the program to the other objects it works with, such as the files in its file specifications and the programs it calls.
  • A warning marks anything that the ingestion layer could not resolve.
  • The readiness status follows how confident the ingestion layer is in what it read.

AS/Forward marks a clean program ready. A program with gaps goes to human review before anyone converts it. We tested the ingestion layer against about 5,000 programs from PUB400 and public code repositories.

Across every program in your libraries, AS/Forward builds the dependency map. In its Migration view, your team picks a field or an object and gets the answer to a plain question: if we touch this, what else moves? AS/Forward also flags code that nothing references, and your team can decide what to retire. Our page on RPG code analysis explains how the Migration view lists the programs and print jobs that one field change reaches.

Your own developers can test a description, because they already know what their programs do. Pick one program that a developer on your team knows well. Ask that developer to compare its program page with what the program does in production.

What the source alone does not show

AS/Forward works from the source, and that leaves two limits. A static cross-reference lists the files and programs that appear in the source. The first limit comes from a runtime call. When a program assembles the name of a called program from a parameter at run time, that name does not appear in any static cross-reference. The value exists only at run time, and no tool that works from source has it.

The second limit comes from an unresolved copy member. That is a copy member the ingestion layer could not find. A program with an unresolved copy member is one of the programs with gaps, and its program page shows a warning.

The programs in those two groups can have dependencies that no static cross-reference lists, and the developers who maintain them can supply what the source leaves out. Ask your developers to check those programs by hand.

Keeping the code in RPG or converting it

With a plain-English description of each program and the dependency map, your team can choose where the code goes next. Every outcome is valid. You can keep the code in RPG and clean it up to free-format, or you can convert it to a language you choose. We do both kinds of work.

Either way, the ready programs can go first. Free-format RPG and Python are two of the languages that AS/Forward converts code to.

The tool does not force a rewrite you did not ask for. AS/Forward runs air-gapped inside your own infrastructure, and its language model stays on-prem with it. It also supports audit preparation and knowledge transfer before any migration.

An IBM i modernization assessment comes first, and it sizes the work. We can run AS/Forward against your RPG library and hand your team the dependency map along with the descriptions.

Tell us about your RPG library

Call us at 501-232-7188 when your team wants a plain-English description of every RPG program in its libraries. Tell us which libraries contain your production RPG source and which program your team wants described first. If your team already leans toward keeping RPG or converting it, tell us that too. If you prefer to write, send the same details to our team in Hot Springs Village, Arkansas, through our contact page.