Programming - Everything You Wanted To Know About Subfiles But Were Afraid To Ask

About Programming - 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

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, "Simple RPG Subfiles for Noobs," 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. 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 Simple RPG Subfile So, I found an old RPGLE Subfile example on a website that is top of the search engine list. This means it's been visited and downloaded thousands of times. But does that mean it's anygood? Don't waste time trying yourself - watch me do it for you :)

RPG Subfile DSPF - A Quick Look at the data description specifications (DDS)

RPG Subfile - Review the RPG program source code - Part 1 COPYBOOK

RPG Subfile - Review the RPG program source code - Part 2 RPG BODY

RPG Subfile - Making this dodgy program compile!

RPG Subfile - Test the RPG program and see what it does

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? 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"}
>