Getting Started with RPG (and Coffee)
The RPG Blend – Real Code, Real Coffee, No Nonsense
Today’s coffee? A bold cup of Green
Mountain Dark Granite—rich, full-bodied, and exactly what you
need when diving into something new. Grab a coffee warmer or your favorite Yeti
mug, and let’s get started.
If you're here, you're curious about RPG—or you're tired of
hearing “IBM i isn’t going anywhere” without knowing why. Let’s fix that. This post is your practical starting
point—just enough caffeine and code to get you going.
Step 1: Sign Up for a Free PUB400
Account
To write and test RPG code, you’ll need access to an IBM i system.
PUB400.com offers exactly that—for free.
Here’s how to get started:
- Visit https://pub400.com
- Click on “Request a User ID.”
- Fill out the form and wait for
your credentials via email (usually within a day).
- You now have access to a real IBM
i system.
Once you’re in, you’ll be able to use tools like the green screen (5250
terminal) to interact with the system.
Step 2: Learn the Basics of IBM i
Before diving into RPG code, take a few minutes to get familiar with the
IBM i environment:
Key Concepts:
- Library Lists: Think of libraries like folders.
A library list defines what data and programs you can see and use.
- Source Physical Files: Where your RPG source code
lives. These are objects that contain members—each member is a source
file.
·
Objects:
Everything on IBM i is an object—programs, files, libraries, queues. Use DSPOBJD
to display information about objects.
·
Message Queue:
Each user has a message queue where the system sends notifications or messages
from jobs. Use DSPMSG
to
view them.
- Commands (CL): Much of what you do on IBM i is
driven by commands. Example: WRKMBRPDM to work with source members.
Common Commands to Try:
- WRKLIBL – Work with your current library
list.
- CHGLIBL – Change your library list.
- DSPLIBL – Display your current library
list.
- WRKMBRPDM – Work with source members in a
source physical file.
- WRKSPLF – View your spooled files (print
output).
- WRKOUTQ – See the contents of output
queues.
- WRKACTJOB – Check current running jobs and
system activity.
- DSPMSG – View system messages for your
session.
- STRPDM – Start the Program Development
Manager tool to access source files and utilities.
Pro
Tips:
- MSGW (Message Wait): A job status where a program is
waiting for user input—usually seen on WRKACTJOB. Investigate and respond using WRKMSG.
- LCKW (Lock Wait): Indicates a job is waiting for a
resource that is locked by another job.
- IFS (Integrated File System): A part of IBM i that acts like a
traditional file system, allowing you to store and access stream files
like PDFs, CSVs, and more.
Try It:
Log in using a 5250 emulator and run each command above.
It’s old-school, yes—but understanding this layer is key.This may feel old-school, but
understanding this layer is key to becoming effective on the platform. These commands give you hands-on
experience navigating the system. Try them out to build confidence before
writing your first program.
Step 2.5: Create Your Own Development
Library and Source Files
Before you start coding, it’s a good practice to create your own
development space on the system. This gives you full control over your programs
and avoids messing with shared or public libraries.
Note:
When your account is created on PUB400, default development libraries—typically
matching your user ID (e.g., GEORGE
, GEORGELIB
, or similar)—are automatically created
for you.
Step-by-Step: Create Your Dev Library
and Source Files
Let’s assume your username is GEORGE. You’ll create:
- A library: GEORGEDEV
- A source file for RPGLE: QRPGLESRC
- A source file for CL: QCLSRC
1. Create Your Development Library
CRTLIB LIB(GEORGEDEV) TEXT('GEORGE DEVELOPMENT
LIBRARY')
2. Create Source Physical Files
CRTSRCPF FILE(GEORGEDEV/QRPGLESRC)
RCDLEN(112) TEXT('RPGLE SOURCE')
CRTSRCPF FILE(GEORGEDEV/QCLSRC)
RCDLEN(112) TEXT('CL SOURCE')
3. Add Your Library to the Top of Your Library List
ADDLIBLE LIB(GEORGEDEV)
POSITION(*FIRST)
This ensures your programs compile into your personal library and not
into a system or shared one.
4. Verify Your Library List
DSPLIBL
Make sure GEORGEDEV is at the top.
Step 3: Write Your First RPG Program
Let’s start with something simple.
Use WRKMBRPDM
to open or create
a source member:
WRKMBRPDM
FILE(GEORGEDEV/QRPGLESRC)
Create a new member HELLO
using F6 or the command below.
STRSEU
SRCFILE(GEORGEDEV/QRPGLESRC) SRCMBR(HELLO) TYPE(RPGLE) text(‘HELLO WORLD’)
Use SEU to enter this code:
**free
DCL-S msg VARCHAR(50) INZ('Hello, RPG
World!');
dcl-s response char(1) inz;
DSPLY msg ‘ ‘ response;
*INLR = *ON;
Press F3 to exit and save.
What’s Happening Here:
- **free
This tells the compiler you're writing in fully free-form RPG. No column restrictions, just clean code like modern languages. - DCL-S msg
VARCHAR(50) INZ('Hello, RPG World!');
- DCL-S declares a standalone variable.
- msg is the name of the variable.
- VARCHAR(50) means it can hold up to 50
characters.
- INZ(...) initializes it with the value 'Hello, RPG
World!'.
- DCL-S response
char(1) inz;
- DCL-S declares a standalone variable.
- msg is the name of the variable.
- CHAR(1) means it can hold up to 1
character.
- INZ(...) initializes it with the value one blank.
- DSPLY msg ‘ ‘ response;
o
This is a quick way to display the contents of the msg variable on the screen. Think of it like print() in Python or console.log() in JavaScript.
o
The ‘ ‘ is a parameter maker for message queue (msgq).
o Declares
a one-character variable called response
initialized with a blank. The program
waits for user input before ending.
- *INLR = *ON;
This ends the program and ensures it releases resources properly. It’s like cleaning up before you exit.
Compile and Run:
- Compile it using CRTBNDRPG:
CRTBNDRPG PGM(YOURLIB/HELLO)
SRCFILE(YOURLIB/QRPGLESRC)
- Run it:
CALL YOURLIB/HELLO
You should see your message on the screen.
Step 4: Set Up VS Code for RPG Development
SEU and PDM are classic, but modern RPG deserves modern tools. VS Code makes
it easier to write, edit, and explore code from your own machine.
What You Need:
1. VS
Code installed: https://code.visualstudio.com/
2. IBM
i Extensions:
Step-by-Step:
1. Install “Code for IBM i”
Open VS Code > Extensions (Ctrl+Shift+X
)
> Search for Code for IBM i
> Install
2. Configure Your PUB400 Connection
·
Open the Command Palette (Ctrl+Shift+P
) > IBM
i: Add Connection
·
Host: pub400.com
·
User ID and Password: from your PUB400 email
·
The port for pub400 is 2222
3. Set Your Working Library
After logging in, set your working library to GEORGEDEV
.
4. Open Your Source Files
Browse your libraries and open members inside QRPGLESRC
.
You can edit RPGLE code in a clean, modern editor with syntax highlighting.
Why Use VS Code?
·
Free-form RPG is easier to write without column
limitations
·
Better syntax highlighting and error checking
·
Push changes directly to IBM i
·
Integrated terminal, Git support, and extensions
Step 5: Create a “Hello World 2”
Program Using VS Code
Now that you’ve connected VS Code to PUB400, let’s write and run your
second RPG program—this time using your modern IDE.
1. Launch VS Code and Connect
- Open VS Code
- Open the Command Palette (Ctrl+Shift+P)
- Type: IBM i: Connect
to an IBM i
- Choose your PUB400 connection (or
create one if you haven’t yet)
- Wait for the status bar to show
you’re connected
You’ll see your user ID in the lower-left corner when connected.
2. Navigate to Your Source File
- In the IBM i Projects
sidebar:
- Expand GEORGEDEV
- Find QRPGLESRC
- Right-click → NEW MEMBER…
- Name: HELLO2
- Type: RPGLE
- Description: Hello World 2
This creates a source member directly in the IFS and opens it in the
editor.
3. Write the Program
Paste this into the open editor tab:
**free
DCL-S msg VARCHAR(50) INZ('Hello
again, RPG from VS Code!');
DCL-S response char(1) inz;
DSPLY msg ‘ ‘ response;
*INLR = *ON;
Click Save (Ctrl+S)
4. Compile the Program
- Click Compile (Ctrl+E)
- Choose CRTBNDRPG from the options
If successful, the output panel will confirm that the program object HELLO2 was created in your GEORGEDEV library.
5. Run It from VS Code
1. Hover
over the PUB400 connection in the bottom status bar of VS Code.
2. Select
Terminals → 5250 Emulator.
3. Sign
in, then run: CALL GEORGEDEV/HELLO2
You’ll see the display output directly in the 5250 emulator window.
Why This Matters
Writing RPG in VS Code avoids the 1980s column restrictions. You get:
- Modern editing experience
- Syntax highlighting
- Compile-on-save capability
- Seamless access to PUB400
VS Code + IBM i makes legacy tech feel current again.
Final Sips
You don’t need to be a mainframe wizard. You just need curiosity, some time,
and a decent cup of coffee.
While much of your early IBM i exploration
happens in the "green screen" terminal, not everything is locked in
the past. IBM i is a rock-solid platform, but it’s not stuck in time. With
tools like VS Code and RDi, you can bring the power of RPG to the modern
developer workflow—one cup at a time.
Modern RPG development gives you:
·
A clean, readable syntax with fully free-form RPG
·
Tools like VS
Code and RDi
that rival any modern IDE
·
A platform that balances stability with flexibility
So yes—learn the green screen basics.
Understand how the system works. But know that powerful, productive, and modern
development is right at your fingertips.
Want to explore the code without copying it from the article?
Check out the full source files on GitHub: https://github.com/Zero-Sub/the-rpg-blend
Coming Up Next…
In the next post, we’ll go hands-on and build a real RPG program that reads
data from a file. We'll introduce input, output, and writing business logic the
RPG way.
Until then:
·
Sign up for PUB400
·
Build your dev library
·
Explore the system
·
Install VS Code
·
And sip slow—your RPG journey just began.
Comments
Post a Comment