Example of an IBM i RPG Single Page Subfile

  • Home
  • /
  • Blog
  • /
  • Example of an IBM i RPG Single Page Subfile

December 1, 2016

Example of an IBM i RPG Single Page Subfile

By NickLitten

December 1, 2016

subfile, example, RPG, RPGLE, sample, SFL, SFLPAG, subfile

What is a single page subfile?

A single page subfile is a SCREEN OF DISPLAYED DATA, loaded one page at a time.

The displayed data is the number of records that are loaded and 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

Jump into this free lesson to see code examples, RPG programming styles and a video walk through helping you to master RPG SINGLE PAGE SUBFILES:

Example of an IBM i RPG Single Page Subfile 1

Example Single Page Subfile in SQL RPGLE

RPG Programming for Beginners

RPG is the well known programming language on the IBM i platform. Earlier versions of RPG ran on the old AS/400 and iSeries machines in decades gone by… the beauty of RPG is that it is fully backwards compatible. But, over the years RPG has evolved massively!

  • Hi Nick,
    Does your IBM i RPG Subfile program run in OS version V5R4 , because I’ve got several highlighted lines in the source code ?
    Thanks in advance.

  • and/or a dynamic-ORDER BY clause.
    Example is when you have multiple of input fields as key-fields when starting to sort, and when these input fields (on the CTL-record-format) have changed it’s values.
    Maybe an exec-sql PREPARE is necessary?
    Please advise. Thank you.

  • Hello Nick! I stumbled upon your free-format RPG and embedded SQL from your website, about single-page subfiles.
    I like your coding style! Thank you! …
    By the way, do you have code-snippets or logic where the program/dspf requires a “Position To”?
    Thanks again!

    • I used to use the DSPF AID byte all the time – but for when creating simple examples I find the mapping the *indicator array a clearer way to explain the function keys. It could, of course, be argued both ways. Both just as good as each other. 🙂

    • Again, agree totally. But.. in this code example I was writing it and showing it to a .net programmer that preferred if/elseif/elseif layout… so his preference just kind of stuck with me. 😉

      When I’m writing my own code I tend to use *SELECT* groups in both RPG and CLLE because I like the indentation layout of them… seems cleaner to my eyes.

  • Argh! I didn’t have **FREE starting in position 1. Now it compiles fine. Sorry for the dumb comments above. I can’t seem to delete my comments.

  • Hello Nick, I found this in doing some research for a project I have and thought it might help but have some issues I can’t seem to resolve.. My project is to display a subfile that can be up to 3 pages long during the day. – It will grow as production grows. There is a program that runs all day that updates the production work file that this program should display. I want it to display a page at a time, pause for X seconds, display the next page, if there, pause, etc. There are no updates, inqs, etc. This is just a display for the shop floor. I’ve tried sleep, dly, %status. Can’t seem to get it. Can you help me? Thanks,

    • Hey Janet
      Sorry this reply is a couple of months old — I suspect you already solved this problem?
      If not, then I’m going to write a blog on how to do this later today. It’s actually an easy solution using record timeouts in the DDS. I’ve written a few things that do exactly this over the years.. will be fun to revisit an old piece of code and modernise it for an example. Watch this space!!!

  • {"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

    Join the IBM i Community for FREE Presentations, Lessons, Hints and Tips

    >