RPG : Everything You Wanted To Know About Subfiles But Were Afraid To Ask

About RPG : Everything You Wanted To Know About Subfiles But Were Afraid To Ask

Let's talk about SUBFILE programming in RPG.

If you have grown up through the world of AS400 a few decades ago, or through the wonderful ISERIES machines of the early 2000's then you *maybe* are using the current IBM i POWER SYSTEMS that replaced those old boxes.

If that's the case, in most places you are using subfiles to display information on those smelly old green screen terminals. Writing a SUBFILE PROGRAM means knowing how to code them, ranging from simple full load, to expanding, to page at a time. Each type of Subfile has different programming styles... so let's dive in and have a play with SUBFILES in RPG Programming.

What is a subfile? A programming technique to display data on the screen in a multi-page format.

What types of subfile? We can code full load, expanding and single page subfiles

Come with me while we look at all the different types of subfiles and go through some RPG and SQL RPG examples from cradle to grave. All modules will look at a range of subfiles from brand new simple examples to modifying someone elses code.

Module Content

Let's talk about SUBFILE programming in RPG. If you have grown up through the world of AS400 a few decades ago, or through the wonderful ISERIES machines of the early 2000's then you *maybe* are using the current IBM i POWER SYSTEMS that replaced those old boxes. If that's the case, in most places you are using subfiles to display information on those smelly old green screen terminals. Writing a SUBFILE PROGRAM means knowing how to code them, ranging from simple full load, to expanding, to page at a time. Each type of Subfile has different programming styles... so let's dive in and have a play with SUBFILES in RPG Programming. What is a subfile? A programming technique to display data on the screen in a multi-page format. What types of subfile? We can code full load, expanding and single page subfiles Come with me while we look at all the different types of subfiles and go through some RPG and SQL RPG examples from cradle to grave. All modules will look at a range of subfiles from brand new simple examples to modifying someone elses code.

Stepping into the world of Subfiles

MEMBERS ONLY

Subfiles are one of those classic IBM i tools that every programmer uses, but few feel they’ve truly mastered. They can look mysterious, behave unpredictably, and let’s be honest - sometimes make you wonder if they’re quietly judging your coding choices. In this lesson, we’ll strip away the confusion and walk through everything you ever wanted to know about subfiles but never quite felt brave enough to ask. From the core concepts to practical, modern techniques, you’ll learn how to build clean, reliable, and user‑friendly subfile applications with confidence.

Let's look at the basics of a subfile and how it works. An IBM i subfile has the same setup as previous generations of AS/400 and iSeries. A subfile is a powerful feature that allows you to display and manage multiple records on a single screen. Let me break it down for you: Purpose of Subfiles: Subfiles are used to present a list of values or records to the user. They allow you to handle multiple records of the same type on a display screen. You can perform actions like scrolling through the list, selecting items, and making changes. How Subfiles Work: A subfile is defined in a display file (DSPF). The records displayed in the subfile are read from a database file through a program. The program writes the records to the device file, which is then displayed on the subfile screen. Types of Subfiles: Load All Subfile: Loads the entire subfile at once. Suitable for smaller datasets. Expanding Page Subfile: Loads a page each time the PAGEDOWN key is pressed. Page at a Time Subfile: Loads one page of records at a time. More efficient for larger datasets.

What is a Subfile? A subfile is essentially a buffer or a temporary storage area in memory that holds a set of records to be displayed on a screen. It’s paired with a display file (defined in DDS - Data Description Specifications) to present data in a structured, scrollable format. Subfiles are ideal for scenarios like showing a list of customers, orders, or inventory items, where users need to interact with multiple records at once.

What are the SFL (Subfile) Indicators and how do they work? SFL | SFLDSP | SFLDSPTCTL | SFLCLR

A subfile is essentially a list of file data on the screen - think of it as a way of looking at information from the system ior an application database. A typical subfile might be entering an ORDER NUMBER and seeing all the ORDER LINES on that order, and being able to scroll up and down through that list. Let's look at some RPG Pseudocode for an RPG subfile and have a glance through the layout and key style for this IBM i Programming solution.

Load All RPGLE Subfile

MEMBERS ONLY

A load all subfile is one in which we generally specify the subfile size as 9999 in the record format itself. However, you may define the subfile size to be less than 9999 in the record format and still load all your subfile at a time. In that situation the records will not be placed at contiguous memory location.

Hey there, future IBM i software wizards! Welcome to 'Simple RPG Subfiles for Noobs - The DSPF - Beginners AS400 iSERIES and IBM i Programmers,' the video where we take the mystery out of subfiles and make you the hero of your own programming saga! Picture this: you’re about to conquer the ancient AS400 beast, armed with nothing but your wits, a keyboard, and a desperate need to impress your boss. Don’t worry if you’re still figuring out what DSPF stands for—by the end of this, you’ll be slinging subfiles like a pro, or at least faking it ‘til Friday. So grab your coffee, mute your Zoom call, and let’s dive into the glorious world of IBM i programming—where the stakes are low, but the bragging rights are epic.

Oh, welcome, brave souls, to 'Simple RPG Subfiles for Noobs - The Old Fashioned RPG AS400 Code - Beginners AS400 iSERIES and IBM i Programmers!' Buckle up for a thrilling ride back to the Stone Age of coding, where RPG on the AS400 reigns supreme and 'modern' is just a dirty word. You’re about to master subfiles—or at least pretend to—on a system so ancient, it probably thinks floppy disks are cutting-edge. Perfect for beginners who love a challenge, or masochists who enjoy debugging in a language older than their parents. Let’s get started—your green screen awaits, you lucky devils!

Alright, imagine you’re a newbie programmer stepping into the wild world of the AS400 iSeries and IBM i, armed with nothing but enthusiasm and a keyboard. This lesson is your trusty guide to mastering the art of RPG subfiles, like little digital drawers where you stash data for your retro-futuristic RPG programs. It’s all about keeping things simple, silly, and beginner friendly. Think of it as learning to herd data like a pro, without getting lost in the techy wilderness of the iSeries jungle. Perfect for those who still think "subfile" sounds like a secret sandwich menu item!

Dive into "Simple RPG Subfiles for Noobs - The IBM-i RPG" and picture yourself as a rookie coder in the AS400 iSeries realm, wielding the power of modern RPG subfiles like a data-slinging wizard! This lesson is your goofy guru, showing you how to ditch the old-school spaghetti code for sleek, modern-style vibes. Why go modern? It’s like swapping a clunky flip phone for a smartphone—your code runs smoother, looks sexier, and doesn’t make other programmers groan. Think tidy subfiles that behave like obedient digital pets, making your IBM i adventures faster, fancier, and way less headache-y!

Welcome to this quick tutorial on building a 'Full Load IBM i RPG Subfile'! In this video, we’ll walk through a simple example of reading all entries from a physical file —also known as an SQL table—and displaying them on the screen using RPG Free Format. Perfect for beginners or anyone looking to master subfile basics, let’s dive in and get those records loaded!

Today, we’re raiding a database file and whipping it into shape with slick, modern RPG style on the mighty IBM i Power System. Picture this: fresh code, smooth processing, and subfiles that pop—none of that dusty old-school vibe here! Whether you’re just stepping into the RPG ring or leveling up your skills, let’s crank up the fun and make that data dance—here we go!

Grab your detective hats, IBM i rookies! Welcome to Debugging RPG File Data Subfiles for Beginners on the awesome IBM i Power System! Today, we’re hunting down those pesky bugs hiding in your subfiles—think of it like a treasure hunt, but with less gold and more ‘Aha!’ moments. Whether your data’s gone rogue or your screen’s playing hide-and-seek, we’ve got the tricks to tame it. Let’s fire up the debugger and squash those glitches—game on!

Expanding Size RPGLE Subfile

MEMBERS ONLY

An expandable subfile is one in which ideally one page of records are loaded at a time. Subsequent pages are added to the subfile when the user presses PAGE DOWN. All previous pages (PAGE UP) are already in memory, so they are handled by IBM i.

Single Page RPGLE Subfile

MEMBERS ONLY

A single page subfile is a SCREEN OF DISPLAYED DATA, loaded one page at a time. The displayed data is equal to the maximum number of records that can be displayed at a time. In other words, in a single page subfile, all loaded records are displayed at a time. We delete all previously loaded records from the subfile whenever we need to load the next page of the subfile. A single page subfile is characterized by the subfile size equaling the page size. Also, in a single page subfile, both ROLLUP and ROLLDOWN keywords must be defined in the DDS of the subfile control format. This is because the PAGEUP/PAGEDOWN activities are handled by the program

A Strangers (Dodgy) Sample Subfile Program

MEMBERS ONLY

Come with me while we step through the code, discuss what it's doing and why it's doing it. I discovered someone else’s sample subfile template for an RPGLE program this morning. It looks quite nice, coded differently to my personal style so let’s (a) have a play with it, and see how it performs, then (b) modernize it to RPG /free and make some small tweaks to see if it can be improved: #IBMi #AS400 #iSERIES #RPG #RPGLE #SUBFILE Then we can compile it. Fix any problems we find along the way and finally... hopefully... end up with a working program.

Introduction to a Stranger’s RPG Subfile invites you into the wonderfully quirky world of subfile programming through the eyes of someone who once stared at a green‑screen listing and thought, “What on earth is this thing doing?” This course breaks down the mystery, guiding you step‑by‑step through how subfiles work, why they’re so powerful, and how you can build them confidently, even if they’ve always felt like an arcane relic left behind by a stranger. Whether you’re brand new to RPG or simply ready to demystify subfiles once and for all, you’ll find clear explanations, practical examples, and a friendly path into mastering one of the IBM i’s most enduring UI tools.

RPG Subfiles – The Data Description Specifications (DDS DSPF) takes you behind the curtain of what really makes a subfile tick. If subfiles are the engine of classic IBM i screens, then DDS is the blueprint that tells that engine exactly how to behave. In this lesson, you’ll explore how display file keywords, record formats, indicators, and layout rules come together to shape the user interface long before a single line of RPG executes. Whether you’ve wrestled with DDS before or you’re finally ready to understand why a stray keyword can make your subfile vanish into the void, this module gives you a clear, practical, and approachable foundation for mastering DSPF design.

**RPG Subfile – Review the RPG Program Source Code, Part 1: COPYBOOK** opens the hood on the foundational building blocks that make your subfile program behave the way it does. Before diving into the main logic, this lesson walks you through the COPYBOOK; the shared definitions, data structures, and reusable components that quietly shape everything your program can do. By understanding how these pieces are organized and why they’re structured the way they are, you’ll gain a clearer view of the program’s architecture and set yourself up for smoother debugging, cleaner enhancements, and more confident development as the course progresses.

**RPG Subfile – Review the RPG Program Source Code, RPGLE BODY** dives into the heart of the application: the executable logic that drives your subfile’s behavior on screen. This lesson walks through the main RPGLE source, showing how initialization, data loading, user interaction, and subfile control all come together in a clean, structured flow. By examining the program’s “living” logic beyond the COPYBOOKs and DDS you’ll see how each routine, indicator, and operation contributes to the final user experience. This is where the subfile truly comes alive, and by the end, you’ll have a clearer understanding of how the moving parts fit together and how to confidently navigate and enhance the code.

**RPG 101 – Subfile 5: Making This Dodgy RPG Subfile Program Compile** tackles the wonderfully chaotic moment every RPG developer eventually faces: taking a crusty, questionable, possibly‑held‑together‑with‑indicator‑tape subfile program and coaxing it into a clean, successful compile. This lesson walks through the common pitfalls, mysterious errors, missing keywords, and head‑scratching quirks that tend to surface when working with older or hastily written code. By the end, you’ll not only understand *why* the compiler was grumpy, but you’ll also have a clearer, more confident approach to troubleshooting and modernizing even the dodgiest of legacy subfile programs.

**RPG Subfile – Test the RPG Program and See What It Does** is where all the pieces finally come together on screen. After exploring the DDS, COPYBOOKs, and RPGLE logic, this lesson walks you through running the program and watching the subfile behave in real time. You’ll see how records load, how user actions trigger program responses, and how the display file and RPG logic interact under the hood. This is your chance to connect theory with practice observing the program’s flow, spotting quirks, and gaining the confidence that comes from seeing your code actually *do* something on the IBM i.

Now that we've walked through this RPGLE subfile example, and have a working version, we have to ask ourselves - IS THIS A GOOD EXAMPLE? **RPG 101 – Subfile 7: Is This Subfile Code Good or Bad** invites you to put on your code‑reviewer hat and take an honest, practical look at the subfile program you’ve been dissecting throughout the course. In this lesson, you’ll evaluate the structure, readability, logic flow, and overall design choices to determine what’s solid, what’s questionable, and what’s downright dodgy. Rather than judging for the sake of criticism, the goal is to sharpen your instincts, learning how to recognize maintainable patterns, spot red flags early, and understand why certain coding habits make life easier (or harder) for future developers. By the end, you’ll have a clearer sense of what “good” subfile code really looks like and how to steer your own programs in that direction. If YES - then what is good about it? If NO - then what is bad? What do we hate? What do we tolerate? What can we improve? If ***** (that is a swear word) then what kind of subfile example would I write? *SPOILER ALERT* This subfile code example is NOT LITTEN APPROVED. Be prepared for some Bawdy Anglo-Saxon Expletives

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