Introduction – What is RPG III?
RPG III is a programming language created by IBM for business applications. It was designed to make it easy to create reports and process data on IBM midrange computers (AS/400 and IBM i systems).
Think of it like this: If modern languages like Python are like writing on a blank piece of paper where you can write anywhere, RPG III is like filling out a form where each piece of information has a specific box it must go in.
Why Learn RPG III?
Many large companies still run their core business systems on RPG III programs. These programs handle payroll, inventory, accounting, and more. Learning RPG III opens doors to well-paying jobs maintaining these critical systems.
Key Characteristics of RPG III
- Fixed Format: Code must be in exact column positions (like an old punch card)
- Business Focused: Designed for reports, file processing, and calculations
- Indicator Based: Uses numbered switches (01-99) to control program flow
- File Oriented: Built specifically to read and write database files
Lesson 1: Understanding the Fixed Format
The most important thing to understand about RPG III is that POSITION MATTERS. Every line of code has specific columns where different parts must go.
Think of it Like a Form
Imagine filling out a paper form where:
- Your name must go in columns 1-20
- Your city must go in columns 21-40
- Your zip code must go in columns 41-45
If you write your zip code in columns 1-5, the form won’t work. RPG III is exactly like this.
Step 1: Understanding the Basic Line Structure
Every RPG III line is divided into columns (positions):
Columns 1-5: Sequence number (optional - usually left blank)
Column 6: Form Type (tells what kind of line this is)
Columns 7-80: The actual code (varies by form type)
The Six Form Types (Column 6)
Column 6 tells the computer what type of line this is:
| Column 6 | Name | Purpose | Simple Explanation |
|---|---|---|---|
| H | Header | Program settings | Like the title page of your program |
| F | File | Define files | Lists what files your program will use |
| E | Extension | Arrays and tables | Lists of related data |
| I | Input | Input record layout | Describes what data looks like coming in |
| C | Calculation | Program logic | Where you write your actual code |
| O | Output | Output formatting | How to format data going out |
Example: Simple Program Structure
H
F* This is the File section - defines CUSTFILE
FCUSTFILE IP E DISK
C* This is the Calculation section - the actual program
C READ CUSTFILE 99
C SETON LR
Line by line explanation:
- Line 1 (H): Header – just an H in column 6
- Line 2 (F*): Comment line (asterisk means ignore this)
- Line 3 (F): Defines a file named CUSTFILE
- Line 4 (C*): Another comment
- Line 5 (C): Read a record from CUSTFILE
- Line 6 (C): Turn on the “Last Record” indicator
⚠️ Common Beginner Mistake:
Putting code in the wrong columns! If you put an F in column 5 instead of column 6, your program won’t compile. Always double-check your column positions.
Lesson 2: Your First RPG III Program
Let’s write the simplest possible RPG III program step by step. This program will:
- Start
- Print “Hello World”
- End
Step 1: Create the Header Specification (H-Spec)
H
What this does: Tells the computer “this is an RPG III program.” The H must be in column 6.
Step 2: Define the Output File (F-Spec)
FQPRINT O F 132 PRINTER
Breaking this down:
- F in column 6 = File specification
- QPRINT (columns 7-14) = File name (system printer)
- O (column 15) = Output file
- F (column 16) = Full procedural (we control it)
- 132 (columns 20-23) = Line is 132 characters wide
- PRINTER (columns 36-42) = This is a printer file
Step 3: Write the Program Logic (C-Specs)
C EXCPT HELLO
C SETON LR
What each line does:
- Line 1: EXCPT HELLO = Print the line named “HELLO”
- Line 2: SETON LR = Turn on Last Record indicator (end program)
Step 4: Define the Output (O-Specs)
OQPRINT E HELLO
O 25 'Hello World!'
What this does:
- Line 1: Names this output line “HELLO”
- Line 2: Print “Hello World!” ending at column 25
Complete Program:
H
F* Define printer file
FQPRINT O F 132 PRINTER
C* Program logic
C EXCPT HELLO
C SETON LR
O* Output specification
OQPRINT E HELLO
O 25 'Hello World!'
💡 Understanding the Flow:
- Program starts
- EXCPT HELLO says “print the HELLO line”
- Computer looks at O-specs and finds HELLO
- Prints “Hello World!” at position 25
- SETON LR ends the program
Lesson 3: Working with Files
Most RPG III programs work with database files. Let’s learn how to define a file step by step.
Understanding File Types
Files can be used in different ways:
- Input (I): Only reading data
- Output (O): Only writing new data
- Update (U): Reading AND changing data
Step 1: Simple Input File
FCUSTFILE IP E DISK
Position by position:
- F (column 6) = File spec
- CUSTFILE (columns 7-14) = File name
- I (column 15) = Input file
- P (column 16) = Primary file
- E (column 19) = Externally described
- DISK (columns 20-27) = Disk file
What Does “Externally Described” Mean?
Simple explanation: The file structure (field names, sizes, types) is defined outside your program in the database. Your program just uses it.
Think of it like: You’re using a pre-printed form where all the boxes are already labeled. You don’t have to describe where each box is – you just fill them in.
Example: Defining Multiple Files
H
F* Input file - customer master
FCUSTFILE IP E DISK
F* Output file - report
FREPORT O F 132 PRINTER
F* Update file - transaction file
FTRANSFILE UF E DISK
This program uses:
- CUSTFILE – reads customer records
- REPORT – prints output
- TRANSFILE – reads and updates transactions
⚠️ Remember:
The P in position 16 (Primary) is special – this file “drives” your program. The program will automatically read this file record by record.
Lesson 4: Calculations and Math
Now let’s learn how to do calculations. In RPG III, calculations are done on C-specs (C in column 6).
The Calculation Line Structure
C Factor1 Operation Factor2 Result Length
Think of it as: Factor1 OperationName Factor2 = Result
Example 1: Simple Addition
Goal: Add 100 + 50
C AMOUNT ADD 50 AMOUNT 72
Breaking it down:
- C (column 6) = Calculation spec
- AMOUNT (columns 9-17) = Factor 1 (first number)
- ADD (columns 18-27) = Operation (add them)
- 50 (columns 28-32) = Factor 2 (second number)
- AMOUNT (columns 33-42) = Result (where answer goes)
- 72 (columns 43-48) = Length (7 digits, 2 decimals)
What happens: Takes AMOUNT, adds 50, puts result back in AMOUNT
Example 2: Multiplication
Goal: Multiply QTY × PRICE
C QTY MULT PRICE TOTAL 92
What happens: QTY × PRICE = TOTAL (9 digits, 2 decimals)
Common Math Operations
| Operation | What It Does | Example |
|---|---|---|
| ADD | Addition | 100 + 50 = 150 |
| SUB | Subtraction | 100 – 30 = 70 |
| MULT | Multiplication | 5 × 10 = 50 |
| DIV | Division | 100 ÷ 4 = 25 |
| Z-ADD | Set to zero then add | Set TOTAL to 0 |
Complete Calculation Example
Calculate: Sales tax on an item
C* Price = 100.00
C Z-ADD 100.00 PRICE 92
C* Tax rate = 0.08 (8%)
C Z-ADD 0.08 TAXRATE 32
C* Calculate tax
C PRICE MULT TAXRATE TAX 92
C* Calculate total
C PRICE ADD TAX TOTAL 92
Step by step:
- Set PRICE = 100.00
- Set TAXRATE = 0.08
- Calculate TAX = 100.00 × 0.08 = 8.00
- Calculate TOTAL = 100.00 + 8.00 = 108.00
💡 Understanding Field Lengths:
The numbers at the end (like 92, 72) tell the size:
- 92 = 9 digits total, 2 after decimal (1234567.89)
- 72 = 7 digits total, 2 after decimal (12345.67)
- 50 = 5 digits, no decimals (12345)
Lesson 5: Making Decisions (IF Statements)
Programs need to make decisions. “IF the customer owes money, THEN send a bill.”
Simple IF Statement
Example: Check if balance is over $1000
C BALANCE IFGT 1000
C EXSR HIGHBAL
C ENDIF
What this means in English:
- IF BALANCE is Greater Than 1000
- THEN Execute Subroutine HIGHBAL
- END of IF statement
IF Operations
| Operation | Meaning | Example |
|---|---|---|
| IFEQ | IF Equal | If STATUS equals ‘A’ |
| IFNE | IF Not Equal | If CODE not equal ‘X’ |
| IFGT | IF Greater Than | If AMOUNT greater than 100 |
| IFLT | IF Less Than | If AGE less than 21 |
| IFGE | IF Greater or Equal | If SCORE ≥ 90 |
| IFLE | IF Less or Equal | If QTY ≤ 10 |
Example: Simple Discount Calculator
C* If amount over $100, give 10% discount
C AMOUNT IFGT 100
C AMOUNT MULT 0.10 DISC 92
C ELSE
C* Otherwise, no discount
C Z-ADD 0 DISC 92
C ENDIF
C* Calculate final price
C AMOUNT SUB DISC FINAL 92
In plain English:
- IF amount is over $100
- THEN discount = amount × 10%
- ELSE discount = 0
- Final price = amount – discount
Multiple Conditions (AND)
Example: Check two things at once
C AMOUNT IFGT 1000
C STATUS ANDEQ 'A'
C EXSR PROCESS
C ENDIF
What this means:
- IF AMOUNT > 1000 AND STATUS = ‘A’
- THEN run PROCESS subroutine
- Both conditions must be true
Real-World Example: Credit Approval
C* Check if customer qualifies for credit
C CREDIT IFGE 5000
C RATING ANDEQ 'GOOD'
C LATE ANDLE 2
C* Approved!
C MOVEL 'APPROVED' STATUS 20
C ELSE
C* Denied
C MOVEL 'DENIED' STATUS 20
C ENDIF
Explanation:
Customer is approved IF:
- Credit limit ≥ $5000 AND
- Rating = ‘GOOD’ AND
- Late payments ≤ 2
If all three are true, STATUS = ‘APPROVED’, else ‘DENIED’
Lesson 6: Loops and Repetition
Loops let you repeat code multiple times. Like saying “Do this 10 times” or “Keep doing this until you’re done.”
The DOW Loop (Do While)
Simple idea: Keep doing something WHILE a condition is true.
Example: Count from 1 to 10
C* Start at 1
C Z-ADD 1 COUNT 30
C* Loop while COUNT is less than or equal to 10
C COUNT DOWLE 10
C* Print the number
C EXCPT DETAIL
C* Add 1 to COUNT
C COUNT ADD 1 COUNT
C ENDDO
What happens:
- Set COUNT = 1
- Is COUNT ≤ 10? Yes, so continue
- Print COUNT
- Add 1 to COUNT (now it’s 2)
- Go back to step 2
- Repeat until COUNT = 11, then stop
Loop Types
| Operation | Meaning | When to Use |
|---|---|---|
| DOWLE | Do While Less or Equal | Repeat while value ≤ something |
| DOWLT | Do While Less Than | Repeat while value < something |
| DOWGT | Do While Greater Than | Repeat while value > something |
| DOWEQ | Do While Equal | Repeat while value = something |
| DOWNE | Do While Not Equal | Repeat while value ≠ something |
Practical Example: Calculate Total Sales
C* Initialize total to zero
C Z-ADD 0 TOTAL 92
C* Read first record
C READ SALESFILE 99
C* Loop until end of file (indicator 99 = end)
C N99 DOW *IN99 = *OFF
C* Add this sale to total
C TOTAL ADD SALE TOTAL
C* Read next record
C READ SALESFILE 99
C ENDDO
C* Print the total
C EXCPT TOTLINE
Step by step:
- Set TOTAL = 0
- Read first record
- If not end of file (N99 = NOT indicator 99):
- Add SALE to TOTAL
- Read next record
- Repeat step 3
- When end of file, print TOTAL
💡 Understanding *IN99:
*IN99 is an indicator. Think of it as a light switch:
- *OFF = switch is off = more records to read
- *ON = switch is on = end of file reached
N99 means “NOT 99” – so “keep going while NOT at end of file”
Simple Fixed Loop
Example: Do something exactly 5 times
C Z-ADD 1 X 30
C X DO 5
C EXSR PROCESS
C X ADD 1 X
C ENDDO
What happens: Runs PROCESS subroutine 5 times
Lesson 7: Indicators Explained Simply
Indicators are like light switches in your program. They can be ON or OFF, and you use them to remember things and control what happens.
What Are Indicators?
Simple analogy: Imagine you have 99 sticky notes on your desk, numbered 01 to 99. You can:
- Flip a note face-up (turn indicator ON)
- Flip it face-down (turn indicator OFF)
- Check if it’s face-up or face-down (test the indicator)
How to Use Indicators
Step 1: Turning Indicators ON
C SETON 25
What this does: Turns ON indicator 25 (like flipping sticky note #25 face-up)
Step 2: Turning Indicators OFF
C SETOF 25
What this does: Turns OFF indicator 25 (flips it face-down)
Step 3: Using Indicators in Conditions
C 25 EXSR ERROR
What this means: “IF indicator 25 is ON, THEN run ERROR subroutine”
The 25 in columns 7-8 means “only do this line if 25 is ON”
Step 4: NOT Indicators
C N25 EXSR GOOD
What this means: “IF indicator 25 is OFF, THEN run GOOD subroutine”
The N means NOT – do this if 25 is NOT on
Practical Example: Error Checking
C* Turn off error indicator
C SETOF 90
C* Check if amount is valid
C AMOUNT IFLE 0
C* Bad amount - turn on error indicator
C SETON 90
C ENDIF
C* Check if status is valid
C STATUS IFNE 'A'
C STATUS ANDNE 'I'
C* Bad status - turn on error indicator
C SETON 90
C ENDIF
C* If no errors, process the record
C N90 EXSR PROCESS
C* If errors, print error message
C 90 EXCPT ERRLINE
How it works:
- Start with error indicator OFF
- Check if AMOUNT ≤ 0 (bad) → turn error ON
- Check if STATUS isn’t ‘A’ or ‘I’ (bad) → turn error ON
- If indicator 90 is OFF (no errors) → process
- If indicator 90 is ON (has errors) → print error
Special Indicators
| Indicator | Name | Purpose |
|---|---|---|
| LR | Last Record | Turns ON to end the program |
| 99 | End of File | Commonly used for EOF (no more records) |
| 01-98 | General Purpose | You can use these for anything you want |
| OF | Overflow | Turns ON when printer page is full |
💡 Best Practice:
Give your indicators meaningful purposes and document them:
C* Indicator usage:
C* 90 = Error detected
C* 25 = High balance customer
C* 50 = Weekend transaction
C* 99 = End of file
Lesson 8: Reading and Writing Files
Now let’s learn how to actually work with database files – reading records, finding specific records, and updating them.
Reading Files Sequentially (READ)
Sequential means reading records in order, one after another, like reading a book page by page.
Basic READ Pattern
C* Read the first record
C READ CUSTFILE 99
C* Loop until end of file
C N99 DOW *IN99 = *OFF
C* Process this record
C EXSR PROCESS
C* Read the next record
C READ CUSTFILE 99
C ENDDO
How it works:
- READ gets one record from CUSTFILE
- If successful, indicator 99 stays OFF
- If no more records, indicator 99 turns ON
- N99 means “while NOT at end of file”
Random Access (CHAIN)
Random access means finding a specific record directly, like looking up a phone number in a directory.
Basic CHAIN Pattern
C* Look for customer number 12345
C Z-ADD 12345 CUSTNO 50
C* Find this customer
C CUSTNO CHAIN CUSTFILE 95
C* If found (indicator 95 is OFF)
C N95 EXSR PROCESS
C* If not found (indicator 95 is ON)
C 95 EXSR NOTFOUND
How it works:
- CHAIN looks for a record with key = CUSTNO
- If found: indicator 95 stays OFF, record data is available
- If not found: indicator 95 turns ON
Writing New Records (WRITE)
Adding a New Customer
C* Set up the new customer data
C Z-ADD 99999 CUSTNO 50
C MOVEL 'John Smith'CUSTNAME 30
C Z-ADD 0 BALANCE 92
C* Write the new record
C WRITE CUSTREC
What happens: Creates a new record in the file with this data
Updating Existing Records (UPDATE)
Changing a Customer’s Balance
C* Find the customer
C CUSTNO CHAIN CUSTFILE 95
C N95 EXSR DOUPDATE
C 95 EXSR NOTFOUND
C
C* Update subroutine
C DOUPDATE BEGSR
C* Add to the balance
C BALANCE ADD 100.00 BALANCE
C* Save the changes
C UPDATE CUSTREC
C ENDSR
Important: You must CHAIN or READ before you UPDATE
Deleting Records (DELETE)
Removing a Customer
C* Find the customer
C CUSTNO CHAIN CUSTFILE 95
C* If found, delete it
C N95 DELETE CUSTREC
Warning: DELETE permanently removes the record!
Complete File Processing Example
H
F* Files
FCUSTFILE UF E DISK
FREPORT O F 132 PRINTER
C* Process all customers
C READ CUSTFILE 99
C N99 DOW *IN99 = *OFF
C* If balance over 1000, add 5% interest
C BALANCE IFGT 1000
C BALANCE MULT 1.05 BALANCE
C UPDATE CUSTREC
C ENDIF
C* Print this customer
C EXCPT DETAIL
C* Read next customer
C READ CUSTFILE 99
C ENDDO
C* End program
C SETON LR
O* Output
OREPORT E DETAIL
O CUSTNO 10
O CUSTNAME 40
O BALANCE 1 55
What this program does:
- Read each customer record
- If balance > $1000, add 5% interest
- Save the updated balance
- Print customer information
- Repeat until all customers processed
⚠️ File Operation Rules:
- READ: Gets next record in sequence
- CHAIN: Finds specific record by key
- WRITE: Adds new record (can’t already exist)
- UPDATE: Must READ or CHAIN first
- DELETE: Must READ or CHAIN first
Lesson 9: Complete Program Example
Now let’s put everything together into a complete, working program. This program will:
- Read a customer file
- Calculate 5% commission on sales
- Print a report showing each customer
- Print totals at the end
Complete Commission Report Program
H* =============================================
H* COMMISSION REPORT PROGRAM
H* Calculates 5% commission on customer sales
H* =============================================
H
F* ============================================
F* FILE DEFINITIONS
F* ============================================
F* Customer file - input
FCUSTFILE IP E DISK
F* Report - output
FREPORT O F 132 PRINTER
F
C* ============================================
C* MAIN PROGRAM
C* ============================================
C
C* Initialize totals
C EXSR INIT
C
C* Process all customers
C READ CUSTFILE 99
C N99 DOW *IN99 = *OFF
C EXSR PROCESS
C READ CUSTFILE 99
C ENDDO
C
C* Print final totals
C EXSR TOTALS
C
C* End program
C SETON LR
C
C* ============================================
C* SUBROUTINES
C* ============================================
C
C* Initialize subroutine
C INIT BEGSR
C* Set all totals to zero
C Z-ADD 0 TOTSALES 102
C Z-ADD 0 TOTCOMM 92
C Z-ADD 0 CUSTCNT 50
C* Print report header
C EXCPT HEADER
C ENDSR
C
C* Process one customer
C PROCESS BEGSR
C* Calculate 5% commission
C SALES MULT 0.05 COMM 92
C* Add to totals
C TOTSALES ADD SALES TOTSALES
C TOTCOMM ADD COMM TOTCOMM
C CUSTCNT ADD 1 CUSTCNT
C* Print detail line
C EXCPT DETAIL
C ENDSR
C
C* Print totals
C TOTALS BEGSR
C* Calculate average commission
C TOTCOMM DIV CUSTCNT AVGCOMM 92
C* Print total lines
C EXCPT TOTLINE
C ENDSR
C
O* ============================================
O* OUTPUT SPECIFICATIONS
O* ============================================
O
O* Report header
OREPORT E HEADER 2
O 50 'SALES COMMISSION'
O 65 'REPORT'
O E HEADER 2
O 15 'CUSTOMER'
O 35 'CUSTOMER NAME'
O 55 'SALES'
O 75 'COMMISSION'
O E HEADER 1
O 75 '----------'
O
O* Detail line (one per customer)
O E DETAIL 1
O CUSTNO 15
O CUSTNAME 35
O SALES 1 55
O COMM 1 75
O
O* Total lines
O E TOTLINE 2
O 40 'TOTAL CUSTOMERS:'
O CUSTCNT Z 55
O E TOTLINE 1
O 40 'TOTAL SALES:'
O TOTSALES 1 55
O E TOTLINE 1
O 40 'TOTAL COMMISSION:'
O TOTCOMM 1 75
O E TOTLINE 1
O 40 'AVERAGE COMMISSION:'
O AVGCOMM 1 75
Program Flow Explained
Step 1: Initialization (INIT subroutine)
- Set TOTSALES = 0
- Set TOTCOMM = 0
- Set CUSTCNT = 0
- Print report headers
Step 2: Main Loop
- Read first customer record
- If not end of file:
- • Run PROCESS subroutine
- • Read next customer
- • Go back to step 2
- When end of file, continue to step 3
Step 3: Processing (PROCESS subroutine)
- Calculate COMM = SALES × 0.05
- Add SALES to TOTSALES
- Add COMM to TOTCOMM
- Add 1 to CUSTCNT
- Print customer detail line
Step 4: Totals (TOTALS subroutine)
- Calculate AVGCOMM = TOTCOMM ÷ CUSTCNT
- Print all total lines
💡 Understanding the Output:
The report will look like this:
SALES COMMISSION REPORT
CUSTOMER CUSTOMER NAME SALES COMMISSION
----------
12345 John Smith 5000.00 250.00
12346 Jane Doe 7500.00 375.00
12347 Bob Johnson 3200.00 160.00
TOTAL CUSTOMERS: 3
TOTAL SALES: 15700.00
TOTAL COMMISSION: 785.00
AVERAGE COMMISSION: 261.67
Lesson 10: Practice Exercises
Now it’s time to practice! Try these exercises to test your understanding.
Exercise 1: Simple Calculator (Beginner)
Goal: Create a program that:
- Sets NUM1 = 100
- Sets NUM2 = 50
- Calculates SUM = NUM1 + NUM2
- Calculates DIFF = NUM1 – NUM2
- Calculates PROD = NUM1 × NUM2
- Prints all results
Hint: Use Z-ADD to set values, then ADD, SUB, MULT operations
Exercise 2: Grade Calculator (Intermediate)
Goal: Read a student file and assign letter grades:
- 90-100: Grade = ‘A’
- 80-89: Grade = ‘B’
- 70-79: Grade = ‘C’
- 60-69: Grade = ‘D’
- Below 60: Grade = ‘F’
Hint: Use IFGE (if greater or equal) operations
C SCORE IFGE 90
C MOVEL 'A' GRADE 1
C ELSE
C SCORE IFGE 80
C MOVEL 'B' GRADE 1
C ELSE
C* ... continue for C, D, F
C ENDIF
C ENDIF
Exercise 3: Inventory Reorder (Advanced)
Goal: Create a program that:
- Reads an inventory file
- Checks if quantity on hand < reorder point
- If yes, calculates order quantity = (max quantity – current quantity)
- Prints reorder report showing items to reorder
- Counts total items needing reorder
- Calculates total order value (quantity × cost)
Sample solution structure:
C* Initialize
C Z-ADD 0 ORDTOT 92
C Z-ADD 0 ORDCNT 30
C
C* Process each item
C READ INVFILE 99
C N99 DOW *IN99 = *OFF
C
C* Check if reorder needed
C ONHAND IFLT REORDER
C
C* Calculate order quantity
C MAXQTY SUB ONHAND ORDERQTY 50
C
C* Calculate order cost
C ORDERQTY MULT COST ORDCOST 92
C
C* Update totals
C ORDTOT ADD ORDCOST ORDTOT
C ORDCNT ADD 1 ORDCNT
C
C* Print this item
C EXCPT DETAIL
C
C ENDIF
C
C* Read next item
C READ INVFILE 99
C ENDDO
C
C* Print totals
C EXCPT TOTALS
💡 Practice Tips:
- Start with the file definitions (F-specs)
- Write the main logic in C-specs
- Add output formatting last (O-specs)
- Test with small amounts of data first
- Add comments to explain what each section does
What’s Next – Modern RPG
Congratulations! You’ve learned the basics of RPG III. Now let’s talk about what comes next.
The Evolution of RPG
RPG has evolved over the years:
- RPG III (1970s-1980s) – What you just learned
- RPG/400 (1988) – Added more features
- RPG IV (1994) – Major upgrade, still fixed format
- ILE RPG (1995-now) – Modern, free-format
What’s Different in Modern RPG?
Same Logic, Different Syntax
RPG III (what you learned):
C BAL IFGT 1000
C EXSR HIGHBAL
C ENDIF
Modern RPG (free-format):
If Balance > 1000;
Exsr HighBalance;
EndIf;
See the difference? Same logic, but no column positions needed!
Modern RPG Benefits
- No column positions – Write code anywhere on the line
- Longer names – Field names can be 4096 characters instead of 6
- Built-in functions – %EOF instead of indicator 99
- SQL integration – Write SQL queries directly in RPG
- Procedures – Better than subroutines
💡 Your Next Steps:
- Practice RPG III: Master the basics with the exercises above
- Learn RPG IV: Same concepts, updated syntax
- Explore ILE RPG: Modern free-format programming
- Study SQL: Learn to embed SQL in RPG
- Understand DDS: Learn how to create externally described files
Career Opportunities
Learning RPG opens many doors:
- Maintenance Programmer: Keep existing systems running
- Modernization Specialist: Convert RPG III to modern RPG
- IBM i Developer: Create new applications on IBM i
- Business Analyst: Understand legacy systems to document them
⚠️ Important:
Even though RPG III is “old,” millions of lines of RPG III code are running critical business systems RIGHT NOW. Companies need people who understand this code. Your new skills are valuable!
Summary: What You’ve Learned
🎓 You Now Know:
- Fixed Format: How column positions work in RPG III
- Form Types: H, F, E, I, C, O specifications
- File Operations: READ, CHAIN, WRITE, UPDATE, DELETE
- Calculations: ADD, SUB, MULT, DIV, Z-ADD
- Decisions: IF/ELSE/ENDIF statements
- Loops: DOW/ENDDO for repetition
- Indicators: Using switches to control program flow
- Complete Programs: How all pieces fit together
Key Takeaways
- RPG III is column-sensitive – position matters!
- Programs flow from top to bottom (unless loops/IFs change it)
- Indicators are like switches – ON or OFF
- Most programs follow: Initialize → Process Loop → Totals → End
- Comments are your friend – document everything!
Practice Makes Perfect
The best way to learn RPG III is to write programs. Start simple:
- Write a program that just prints “Hello”
- Add calculations (add two numbers)
- Add file reading (process a small file)
- Add decisions (if amount > 100 do something)
- Add loops (process all records)
- Combine everything into complete programs
Keep this tutorial as a reference. Come back to it when you need to remember how something works. Good luck with your RPG programming journey!


