Est. 2001 Intermediate

RPG IV Free-Form

The modern, column-free syntax for IBM's RPG IV (ILE RPG) language, bringing the long-running business programming language of the IBM i platform into a readable, structured form free of its punched-card heritage

Created by IBM

Paradigm Multi-paradigm: Procedural, Modular (with ILE interop to C, C++, COBOL, and Java)
Typing Static, Strong
First Appeared 2001
Latest Version Delivered with IBM i and enhanced through Technology Refreshes (IBM i 7.5, 2022)

RPG IV Free-Form is the modern, column-independent way of writing programs in RPG IV (officially ILE RPG), IBM’s long-running business programming language for the IBM i platform — the operating system whose lineage runs through the AS/400, iSeries, and System i. Rather than a separate language, free-form RPG is an evolution of syntax: it lets developers write RPG without the rigid, punched-card-derived column rules that defined the language for most of its history, producing code that reads much like other mainstream structured languages while remaining fully compatible with the rest of the RPG ecosystem.

History & Origins

RPG’s roots reach back to 1959, when IBM released the original Report Program Generator as a tool for producing business reports on early computers. Its design was openly shaped by the punched-card and unit-record equipment of the era: a program was a deck of cards, and each statement’s meaning depended on which columns its characters occupied. That column dependence carried through RPG II (introduced with the System/3 around 1969), RPG III (for the System/38 and later the AS/400), and RPG/400.

The modern foundation arrived in 1994, when IBM shipped RPG IV — also called ILE RPG — as part of OS/400 V3R1. RPG IV integrated the language into IBM’s Integrated Language Environment (ILE), added the longer Extended Factor-2 calculation specification, and modernized data definitions. Even so, RPG IV programs were still written in fixed-format specifications, where Header (H), File (F), Definition (D), Calculation (C), and Output (O) specs each occupied prescribed column ranges.

The free-form story begins in 2001. With OS/400 V5R1, IBM introduced free-format calculation specifications: by bracketing code between the /FREE and /END-FREE compiler directives, programmers could finally write calculation logic without fixing the operation code and operands to particular columns. This made RPG calculations look much more like C, Pascal, or other general-purpose languages, with operations such as EVAL and CALLP where the opcode was often optional.

For more than a decade, free-form was limited to the calculation specs — file and data definitions still had to be fixed-format. That changed in 2013, when IBM i 7.1 Technology Refresh 7 (delivered via PTF SI51094, around November 2013) introduced fully free-form RPG. By placing the **FREE directive at the top of a source member, developers could now write control, file, data-definition, and procedure statements in free-form too — effectively breaking RPG’s remaining ties to the punched card. A further refinement came around November 2015 (IBM i 7.2 TR3 and 7.1 TR11), which lifted the lingering restriction that free-form code occupy only columns 8–80, allowing source to start in column 1 and extend toward column 240.

Design Philosophy

Free-form RPG IV is built on a pragmatic goal: modernize the syntax without breaking the past. Several principles follow from that:

  • Readability over column discipline. Code is laid out by indentation and ordinary spacing rather than by fixed column positions, so it is easier for newcomers — and developers coming from C-family languages — to read and maintain.
  • Backward compatibility. Free-form and fixed-format code can coexist. RPG IV programs can mix free-form calculation blocks with traditional specs, which lets teams modernize incrementally rather than rewriting everything at once.
  • Strong, static typing. Like its predecessors, free-form RPG keeps strong, statically declared data definitions, giving the compiler full knowledge of field lengths, decimal precision, and data structures.
  • Tight platform integration. RPG is designed around the IBM i platform and its integrated Db2 for i database, so data access — whether native record-level I/O or embedded SQL — is a first-class part of the language.

Key Features

  • Column-free source. With **FREE, statements are written without the legacy column zones, using free spacing and indentation.
  • Free-form declarations. Modern keywords replace fixed-format specs: ctl-opt for control options (formerly the H-spec), dcl-f for files (F-spec), dcl-s, dcl-ds, dcl-c, dcl-pr, and dcl-proc for standalone fields, data structures, constants, prototypes, and procedures.
  • Structured operations. Free-form embraces structured constructs — if/elseif/else, for, dow, dou, select/when, monitor/on-error — and expression-based assignment with eval.
  • Modular procedures and ILE. Subprocedures, prototyped calls, and service programs let developers build reusable, modular code that participates in IBM’s Integrated Language Environment alongside C, C++, COBOL, and CL.
  • Embedded SQL. In SQLRPGLE source, developers embed SQL statements directly to perform set-based queries and updates against Db2 for i.
  • Rich built-in functions. A large library of %-prefixed built-in functions (BIFs) — such as %trim, %scan, %subst, %char, and %date — handles string, numeric, and date manipulation cleanly.

A small free-form example

**free
ctl-opt dftactgrp(*no);

dcl-s greeting varchar(50);
dcl-s name varchar(20) inz('World');

greeting = 'Hello, ' + %trim(name) + '!';
dsply greeting;

return;

Evolution

Free-form RPG IV has matured steadily through IBM i Technology Refreshes (TRs) rather than big-bang releases. After the foundational steps of 2001 (free-form calcs), 2013 (fully free-form definitions), and 2015 (full column freedom), later refreshes across IBM i 7.3, 7.4, and 7.5 continued to extend the free-form language with features such as nested data structures, additional built-in functions, improvements to working with arrays and data structures, and ongoing tooling support. IBM communicates many of these enhancements through the RPG Cafe developer channel. Modern development is also supported by graphical tooling — notably Rational Developer for i (RDi) — which complements (and for many shops replaces) the traditional green-screen SEU editor.

Current Relevance

RPG remains a strategically important language for the thousands of organizations running business-critical systems on IBM i. Free-form is now the recommended style for new RPG development, and a great deal of effort across the IBM i community goes into modernizing older fixed-format applications into free-form — improving readability, easing onboarding of new developers, and integrating RPG logic with web services, APIs, and modern front ends. While RPG is not a general-purpose language found outside the IBM i platform, on that platform it continues to be actively developed, taught, and deployed.

Why It Matters

RPG IV Free-Form is a striking example of a decades-old business language successfully shedding its most dated trait — column-bound, punched-card-style source — without sacrificing the compatibility and reliability that made it valuable in the first place. It lets enterprises protect enormous investments in proven business logic while making that code approachable to a new generation of programmers. In doing so, free-form RPG bridges the gap between the midrange computing heritage of the AS/400 and the expectations of modern software development, keeping one of the most enduring business languages relevant well into its seventh decade.

Timeline

1959
IBM introduces the original RPG (Report Program Generator), a column-oriented, fixed-format language for generating business reports, the ancestor of all later RPG dialects
1994
RPG IV, also known as ILE RPG, is released as part of OS/400 V3R1, modernizing the language and integrating it with the Integrated Language Environment (ILE)
2001
Free-format calculation specifications are introduced with OS/400 V5R1, using the /FREE and /END-FREE directives to free C-specs from rigid column positions
2013
IBM i 7.1 Technology Refresh 7 (PTF SI51094, around November 2013) introduces fully free-form RPG with the **FREE directive, allowing control, file, data-definition, and procedure statements to be written free-form
2015
Around November 2015, IBM i 7.2 TR3 and 7.1 TR11 lift the remaining column restriction, letting fully free-form code begin in column 1 and extend toward column 240
2018
IBM i 7.3-era Technology Refreshes continue adding language features such as nested data structures, new built-in functions, and enhanced support for working with data structures and arrays in free-form
2022
IBM i 7.5 ships, with RPG continuing to receive enhancements through ongoing Technology Refreshes and the RPG Cafe community channel

Notable Uses & Legacy

Enterprise business applications on IBM i

Free-form RPG IV is widely used to write and modernize core line-of-business applications — order entry, inventory, billing, and accounting systems — that run on IBM i (formerly AS/400, iSeries, System i) servers in manufacturing, distribution, banking, and insurance.

Legacy modernization projects

Organizations with decades-old fixed-format RPG code use free-form RPG IV as the target syntax when refactoring and modernizing applications, often with conversion tools such as ARCAD Transformer RPG that translate fixed-format C-specs into readable free-form.

Embedded SQL data access

Free-form RPG IV is commonly combined with embedded SQL (SQLRPGLE), letting developers write set-based Db2 for i queries inside readable free-form programs rather than relying solely on record-level native file access.

Web and API back ends on IBM i

Free-form RPG procedures are exposed as web services and REST/SOAP APIs (for example via IBM's Integrated Web Services) so that modern web and mobile front ends can call business logic that still lives in RPG on IBM i.

ISV packaged software

Many independent software vendors who sell ERP and industry-specific packages for the IBM i platform write new modules and maintain existing ones in free-form RPG IV, taking advantage of its modular procedures and ILE service programs.

Language Influence

Influenced By

RPG III RPG/400 RPG IV

Running Today

Run examples using the official Docker image:

docker pull
Last updated: