RPGLE Free Format Tutorial

Hello World RPGLE Tutorial

Hello world RPGLE Tutorial takes you through the steps to create and run a RPG IV program. In this tutorial, I am...

Written by AS400i · 2 min read >

Hello world RPGLE Tutorial takes you through the steps to create and run a RPG IV program.

In this tutorial, I am going to show how to create a simple free format RPGLE program step by step using IBM Rational Developer and Program Development Manager in AS400 emulator which is commonly use as green screen or 5250 emulator.


Following are the parts we will discuss in this tutorial,

  • Initial setup for RPGLE Free format
  • Entering free format RPGLE code
  • Compilation of RPGLE code
  • Run the program

First of all, I assume you are using one of two ways to do your coding:

  1. IBM RDi

If you are wondering what IBM Rdi is ?, it’s an IDE which provides an integrated development environment to create, maintain and modernise applications on the IBM i platform. I have wrote a comprehensive article about IBM Rdi here – IBM Rational Developer for i

  1. PDM and SEU through some type of 5250 emulator

If you are new to SEU editor I propose you to go through Use of SEU Editor which explains dozen if SEU line commands which will improve your experience in SEU editor.

Initial setup for RPGLE Free format

If you are using IBM RDi:

Create a connection to your IBM i.

Then create a library and remember the name of the library you create because you need it later when you call your first program. (Replace yourlibrary in the instructions with the name of the library you created.)

After that, Create a source file.

And create a source member in the file called HELLO.RPGLE.

Open the member in the editor.

If you are using SEU:

Log on to a session on your IBM i.

Create a library by using the CRTLIB command.

CRTLIB command window

Create a source file by using the CRTSRCPF command.

create a source file as QRPGLESRC using CRTSRCPF command

If you are not familiar with Creating Libraries and Source Physical Files, you can follow Create Library and Source Physical Files article which explains creating libraries and conventions of source physical file naming step by step.

WRKMBRPDM specifying your library and source file.

WRKMBRPDM Command Window

Create a source member HELLO in the file by using F6 in WRKMBRPDM or by using the ADDPFM command, giving it type RPGLE.

Create RPGLE File using STRSEU command
Create RPGLE File

Open the member in SEU by using the “2” option.

Open File in SEU using option 2
Open File in SEU

Entering the RPGLE Free Format program statements

Type the following code and When you type be sure that the first **FREE goes in column 1 of line 1. If you are using RDi, the editor shows you all the columns but if you are using SEU, the editor does not show you columns 1-5 by default, so the first column you see is column 6. Use F19 to shift the code left so you can see column 1.

Source code of 'Hello World' RPGLE Free Format program
DSPLY ‘Hello World’

Differences between Free format RPG and conventional RPG can be found here Differences between Free Format vs Legacy Fixed Format

Compile RPGLE Free Format program

If you are using RDi, you can compile from the menu within the editor, or you can save your changes and compile by right-clicking on the member in the navigation. Either way, select the CRTBNDRPG command, and take all the defaults.

If you are using SEU, exit the editor by using F3, and compile by using option 14 also You could compile from the command line by using the CRTBNDRPG command, and by using F4 to prompt the command.

Save Program on Exit screen
Save Program

Warning: SEU gives errors for every free-form H, F, D, or P statement Therefore RPG syntax checker used by SEU was last updated in 6.1, so it does not understand the new syntax. If you still want to use SEU, you have to exit with errors after you save your source.

Run the Program

If you are using RDi, log on to a session on the IBM i by using an emulator

If you are using PDM, you are already logged on,

Use the CALL command to call the HELLO program, substituting the name of your library for yourlibrary.

CALL Program using command CALL LibraryName/FileName
CALL Program

It puts up a message saying “DSPLY Hello World”

Result of Hello World RPGLE Free Format Program

Just press ENTER to end the program and That is the end of Hello World RPGLE Tutorial, In next chapter we can focus on compilation error handling.

Next tutorial

Source : IBM Developer Portal

why dont you add your experience here