A D1DRRN 4S 0H SFLRCDNBR
...is incremented as each record is loaded. This field needs to be set back to 1 once the subfile has been built, because the page that contains the record whose record number is in that field is the page that will be displayed first -- that's why you see the last page in the subfile.
This is a useful feature. When you read the subfile, you can set the SFLRCDNBR field to the RRN of the first record in error (for example), or to the RRN of the record at the top of the page the user was displaying when control returned to your program, which allows you to show the same page to the user when you return control back to the screen.
There are plenty of tutorials on subfiles. These are some I recommend:
Dig Deeper on Debugging
Related Q&A from John Blenkinsop
When an error occurs on an IBM command, the diagnostic messages are sent first, then an escape message, which you can monitor. On AS/400 you see the ... Continue Reading
Learn how to 'append data to the file' with the FTP DIR command, and eliminate the hassle of having to end the FTP session and restart to view ... Continue Reading
RPGIV will 'think of' incoming integer fields as binary, and then will redefine them in the program structures as PACKED. So, when you chain a record... Continue Reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.