RPG : Learn to program for beginners

About RPG : Learn to program for beginners

Come with me while we talk about the IBM RPG (Report Program Generator) language. We will step through some basics of the language, discuss some history and even get our hands dirty with a little programming. It's an old language and has evolved a lot over the years -- modern RPG is unrecognizable from the old column based code from the 1980's. Let's dive in and start at the beggining.
This will be fun!
Honest ;)

RPG Programming for Beginners

RPG for Beginners

RPG is the well known programming language on the IBM i platform. Earlier versions of RPG ran on the old AS/400 and iSeries machines in decades gone by... the beauty of RPG is that it is fully backwards compatible. But, over the years RPG has evolved massively!

If there was a quick and easy solution to “how to quickly become a productive RPG IV and ILE programmer” then all of us old AS400, iSeries, and IBM I developers would have gobbled up that solution in double-quick time.

Upgrading your programming skills from RPG OPM (Original Programming Model) to RPG ILE (Integrated Language Environment) can seem daunting.

  • If you are a complete programming noob then this RPG Programming course might be useful
  • If you are a software developer looking to add RPG (or RPGLE) to your skillset then this might not be completely useless
  • If you are an old school RPG programmer looking to add some modern programming style to your skillset then this might be something you actually kind of enjoy
  • Or, if you just want to get an idea of what RPG is, what RPG looks like and what RPG can do?

RPG really is much easier than it seems!

Modern RPG is just old RPG with some bells and whistles – if you know old style RPG then you already have the building blocks to expand into the shiny modern world of ILE RPG.

RPG Free form - add FREE in line 1

So, if you are an experienced legacy RPG Programmer but haven't kept abreast with the huge changes to RPG over recent years, don't be put off. It’s not as daunting as it seems. You can easily become more familiar with ILE RPG (also confusingly called RPG4, RPG5 or RPG /Free) just by running older RPG source through IBM’s CVTRPGSRC command.

Comparing the new source members with the originals lets you easily compare the source code layouts and the general formatting differences. For 99.9% of source members, the resulting source should compile as a program that works the same as the original.

Let's start with an easy example of taking a very simple (4 line) RPG/2 program and modernizing it through RPG3, through RPG400 and ending in RPGLE /Freeformat

Module Content

Come with me while we talk about the IBM RPG (Report Program Generator) language. We will step through some basics of the language, discuss some history and even get our hands dirty with a little programming. It's an old language and has evolved a lot over the years -- modern RPG is unrecognizable from the old column based code from the 1980's. Let's dive in and start at the beggining. This will be fun! Honest ;)

IBM i RPG - So much more than a Report Program Generator

MEMBERS ONLY

General info about RPG - This chapter introduces you to general information about RPG source code.

Variables and procedures - This chapter introduces you to defining constants, variables and prototypes.

Introduction to Files / Tables - This chapter introduces you to using files with RPG

Text lesson

Display files - This chapter introduces you to using display files, also called "workstation files"

Solutions to RPG exercises - every question has an answer

Learning to code is most effective if you start with some clean coding standards. So let's start building those foundations properly with advice for RPG, RPG400 and modern ILE RPG programmers.

IBM i RPGLE Programming Language - Declarations

MEMBERS ONLY

Welcome to a tasty lesson on using DCL-C in IBM i RPGLE, brought to you by the one and only Nick Litten. We’re cooking up some code in CodeSlice Pizzeria, where constants keep our pizza orders as stable as a well-baked crust. Let’s dive in!

This lesson dives into the DCL-S statement in IBM i RPGLE. DCL-S is your go-to for declaring standalone variables, the ingredients that make your program as flexible as a pizza dough toss. We’ll cover every variation of DCL-S with a pizza-ordering example that’s hotter than a fresh pie. Let’s get started!

This lesson serves up another slice of programming goodness at CodeSlice Pizzeria. Come with me and let's dive into the DCL-DS statement in IBM i RPGLE. We’re building a pizza order with data structures to keep things as organized as a perfectly sliced pie. Let’s get coding!

Welcome to CodeSlice Pizzeria’s file-handling extravaganza! This lesson, dives into the DCL-F statement in IBM i RPGLE. DCL-F is your ticket to managing files like pizza order slips, logs, and receipts with the precision of a master chef. We’ll explore file declarations with a pizza-ordering example and cover all the key variations. Grab a slice and let’s dig in!

IBM i RPGLE Programming Language - Operation Codes

MEMBERS ONLY

These RPG operation Codes handle mathematical calculations - ADD

These RPG operation Codes handle mathematical calculations - DIV (Divide)

These RPG operation Codes handle mathematical calculations - MULT (Multiply)

These RPG operation Codes handle mathematical calculations - SQRT (Square Root)

These RPG operation Codes handle mathematical calculations - SUB (Subtract)

These RPG operation Codes handle mathematical calculations - Z-ADD (Zero and Add)

These RPG operation Codes handle mathematical calculations - Z-SUB (Zero and Subtract)

These RPG operation Codes handle ARRAY operations - LOOKUP (Look Up a Table or Array Element)

These RPG operation Codes handle mathematical calculations - MULT (Multiply)

These RPG operation Codes handle RPG Array Operations - XFOOT (Summing the Elements of an Array)

These RPG operation Codes handle RPG Bit Operations - BITOFF (Set Bits Off)

These RPG operation Codes handle RPG Bit Operations - BITON (Set Bits On)

These RPG operation Codes handle RPG Bit Operations - TESTB (Test Bit)

These RPG operation Codes handle RPG Branching Operations - CABxx (Compare and Branch)

These RPG operation Codes handle RPG Branching Operations - CASxx (Conditionally Invoke Subroutine)

These RPG operation Codes handle RPG Bit Operations - TESTB (Test Bit)

These RPG operation Codes handle RPG Branching Operations - GOTO (Go to)

These RPG operation Codes handle RPG Branching Operations - ITER (Iterate)

These RPG operation Codes handle RPG Branching Operations - LEAVE (Leave a Do/For Group)

These RPG operation Codes handle RPG Branching Operations - TAG (Tag)

These RPG operation Codes handle RPG Call Operations - CALL (Call a Program)

These RPG operation Codes handle RPG Call Operations - CALLB (Call a Bound Procedure)

These RPG operation Codes handle RPG Call Operations - CALLP (Call a Prototyped Procedure or Program)

These RPG operation Codes handle RPG Call Operations - PARM (Identify Parameters)

These RPG operation Codes handle RPG Call Operations - CALLP (Call a Prototyped Procedure or Program)

These RPG operation Codes handle RPG Call Operations - PARM (Identify Parameters)

These RPG operation Codes handle RPG Call Operations - PLIST (Identify a Parameter List)

Getting Started with RPG Free-Form Programming

MEMBERS ONLY

Getting Started with IBM i RPG: For those who are just exploring the wonderful RPG language - there are lots of wonderful *FREE* guides out there in internet land. I've pulled them together, re-written, updated, freshened and tweaked them for easy reference

Welcome to your first deep dive into the world of IBM i RPG programming, where variables and procedures are the building blocks of clean, modern code. In this lesson, we’ll strip away the mystery behind RPG declarations and show you how to wield them like a pro. Whether you're defining simple constants, crafting structured data with DCL-DS, or modularizing your logic with procedures, you'll learn how to write code that's readable, reusable, and ready for the real world. Think of this as your RPG toolkit: once you master these essentials, the rest of your programming journey becomes a whole lot smoother, and dare we say, more fun. Let’s get started!

Welcome to the heart of RPG programming where variables and procedures turn static code into dynamic, reusable logic. In this lesson, we’ll explore how to declare and use variables with clarity and precision, from simple scalars to structured data definitions. Then we’ll dive into procedures, the modular powerhouses that help you write cleaner, more maintainable programs. Whether you're just starting out or brushing up on modern RPG techniques, this is your launchpad to writing smarter, more efficient IBM i code. Let’s roll up our sleeves and start building!

Welcome to the world of display files where your RPG programs finally get a face! In this lesson, we’ll explore how workstation files (aka display files) allow RPG applications to interact with users through screens, menus, and prompts. Whether you're building a simple data entry form or a full-blown interactive interface, display files are your gateway to user-friendly IBM i applications. We’ll break down how to define them, link them to your RPG logic, and handle input/output operations with flair. Ready to make your RPG code talk to the outside world? Let’s light up the screen.

In this lesson, we’ll take a high-level tour of RPGLE (Report Program Generator Language Enhanced), the evolved form of RPG that powers robust business applications on IBM i systems. You’ll learn how RPGLE blends legacy reliability with contemporary syntax, making it easier to write clean, modular, and maintainable code. We’ll touch on free-form layout, data declarations, procedures, and the tools that make RPGLE a joy to work with in today’s development environments. Whether you're coming from fixed-format RPG or just starting fresh, this overview sets the stage for everything that follows. Let’s dive in and decode the magic behind RPGLE.

Modern RPG : Sub Procedures

MEMBERS ONLY

Probably my favorite RPG enhancement over the years. Coming from RPG3/400 to RPGLE this is something you will definitely need to learn. It’s been used extensively everywhere I’ve worked since leaving the boundaries of ‘JBA’ code and Green screen land

An IBMi RPG sub-procedure is a modular piece of code within an RPG (Report Program Generator) program on the IBM i Power System (the replacement for the IBM iSeries and even older AS400).

In RPGLE (especially free-form RPG), a prototype is like a function signature, it defines how a program or procedure can be called. Think of it as the "contract" that spells out the name, parameters, and return type of a callable routine, without actually implementing it.

in RPG (Report Program Generator), subprocedure parameters can be optional. This is achieved by specifying default values for the parameters in the procedure interface. When a parameter has a default value, it can be omitted when the subprocedure is called, and the default value will be used instead. So, let's play with an example and look at OMIT and NOPASS

IBM is adding all kinds of new tweaks to RPG with each new release of IBM i. RPG ON-EXIT is a great example of a neat tweak to the RPG programming language. In 2016, IBM quietly introduced a rather neat new function called “ON-EXIT” to our sub procedures in RPG.

Writing RPG ILE Programs on your IBM Power System

MEMBERS ONLY

Let's have a look at the most simple version of an old RPG program. A 2 line HELLO WORLD example, written in column based RPG400 (aka RPG3) which will simply send a message to the screen. We can do this using SEU, Source Entry Utility, and integrated text editor on your IBM i Power System - which has remained unchanged for over 20 years :)

Welcome back to part 2 of "programming like an AS400 Noob" ;) In this video we can look at our original simple HELLO WORLD code sample and uplift it to RPGLE format. We can have a quick spin through the PDM development environment and look at some command line tricks.

Yep. You guessed it! In this thrilling episode we are going to take that old column based RPGLE code and set it free. Take our first tentative steps into the world of free format RPG code.

In this, the penultimate episode of "playing with smelly old RPG code" we take the final step into the world of modern RPG code layout. Introducing the **FREE command line, we finally tell the IBM i Compiler that we are not messing about.

Welcome back to final episode of this "RPG for complete noobies" series. Here we will poke around in some modern RPG code, and use Microsoft code editor (Visual Studio Code) to edit the RPG in real time on our IBM i Power System. How does VSCODE know about RPG? By using the marvelous CODE4I plugin of course!

RPG 101 Ep6: Tweaking Hello World to Make It a Bit More Fancy Let's upgrade this super simple HELLO WORLD program to add some more standards and functions In this final flourish of the RPG 101 series, we take our humble Hello World program and give it a stylish upgrade. This lesson shows how to add a touch of polish to your RPGLE code—introducing better formatting, cleaner output, and a few best practices that elevate your code from functional to fabulous.

Beginners Overview of an RPG400 File Update Program

MEMBERS ONLY

Come with me, while I play with someone else's old RPG400 code which performs a *PF file update and allows paging forward and backward through the data... then we will refactor that old ISERIES COLUMN BASED RPG to modern IBM i RPG ILE Freeformat and test it. Assuming that works... then we will upgrade the *PF to an *SQL TABLE and prove that it works with the program without needing any recompiles. Sounds like a fun Friday evening ;)

Are you a novice IBM RPG programmer, or perhaps just a techno junkie who likes to learn about new programming languages? Then this breakdown of some other programmers old RPG400 file update program might be something that you will enjoy. I hope you do. I get strange enjoyment from playing with chunks of code like this... and figuring out what makes them tick.

Let's take a deep dive into this RPG400 program to try and figure out how it works. This will mean looking at the file and display setting to understand the relationship with the RPG code. We are going through it line by line to understand it, compile it and test it. After that... then we can look at upgrading the code to modern FREE FORMAT RPG and upgrade the physical file to an SQL TABLE. Put on your dive mask... and dive in!

Time to dive into the existing RPG400 (Column Based Old Style RPG) and set it FREE. This means using Visual Studio Code, and the Code4i plugin, to automatically upgrade the old legacy code style to modern free format RPG ILE. This does a pretty good job easily upgrading 90% of the code - so come with me while I walk through the code base and manually fix the few lines it couldnt automatically handle. SPOILER ALERT - don't laugh at me when I make RPG conversion mistakes. They are deliberate. Honest ;)

Come with me, while we trawl through this old code and update to a newer style of subroutine - the much lauded RPG SUB PROCEDURE

Let's convert our physical file to an SQL Table two ways, once using my toolkit command from PROJEX4i, or for those that don't want to download and install the toolkit onto their IBM i System, we will also use IBM i Access Client Solutions itself. We will check the file record format level ID to prove that the new TABLE looks just like the old PF and all existing RPG code will simply run over the new TABLE without needing any recompiles.

Modern RPG : Service Programs

MEMBERS ONLY

An IBM-i Service Program is a collection of reusable procedures and data items that can be accessed by other Integrated Language Environment (ILE) programs or service programs on the IBM i (AS400/iSERIES) system.

A Simple IBM i RPG Service Program is a program written in the RPG (Report Program Generator) language, designed to provide basic functionality and services for applications running on the IBM i (formerly known as the AS/400) platform.

RPG service programs provide a powerful way to organize and manage your code, making development more efficient and your applications more reliable. Are you working on a specific project where you’re considering using service programs?

Let's flesh out this service program and add new procedures as we need them

Welcome to Visual Studio Code for IBM i and Service Programs! In this video, we’re diving into the power of VS Code to supercharge your IBM i development, with a spotlight on creating and using service programs. Let's take a ten year old service program, modernize it and talk through how it works. Service programs are easy! Whether you’re coding RPG, managing modules, or just tired of green-screen editors, we’ve got the tips to streamline your workflow. Let’s plug in, power up, and make some modular magic, so stick around! Key Topics Covered What are Service Programs? Reusable modules that encapsulate procedures and logic. Help reduce code duplication and improve maintainability. Why Use VS Code for IBM i? Offers a modern, flexible development environment. Integrates with tools like the Bob (Build Open Blocks) builder for compiling and managing service programs. Workflow Demonstration Shows how to set up service programs in VS Code. Explains how to compile and bind modules using Bob. Highlights how binder language and binding directories work together.

Write Clean Code

MEMBERS ONLY

Debugging RPG Programs on IBM i: A Beginner’s Guide to Squashing Bugs Whether you’re slinging legacy RPG or rocking the modern Free Format vibe on the IBM i Power System, one thing’s for sure: bugs happen. Those sneaky little gremlins can turn your perfectly planned subfile into a head-scratcher. But fear not—debugging RPG programs is a skill you can master, and I’m here to walk you through the basics. Let’s fire up the IBM i debugger and get those programs back on track!

Ready to learn?
{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
>