Page at a time subfile

895 pts.
AS/400 Subfiles
I want to code loading a single page subfile in SQLRPGLE. How do I handle the page up and page down key, posotion to in that program?



Software/Hardware used:

Answer Wiki

Thanks. We'll let you know when a new response is added.

Hopefully I have remembered to include everything of import here. I didn’t include things like command key handling. You’ll obviously have to fill in the blanks. But having coded on this platform for 27 years (I can’t believe it!), I’ve found this to be a tried and true basic technique.

If you plan to load from a point in the data and be able to page down, use this technique. You can make it go back and forth, but I’ve found my users were quite satisfied with this method.

Note, If you aren’t allowing the user to select a subfile record and process it, you don’t need to save the relative record number or file keys. In that case, use READP after the end of the fill loop to position to the correct record for the next subfile page and skip the setll on pagedown.

– Specify PAGEDOWN keyword with a response indicator
– Specify SFLEND keyword conditioned with a file read indicator
(I don’t normally use file access indicators, but in this case it works well)
– Specify a position to field on your subfile control record

– Loop
– Execute your format
– Check to see if the position to field is changed.
– If so, clear the subfile and using the position to field key(s), setll to your file, execute fill subroutine
– Did they page down?
– If so, setll with saved keys and restore your saved subfile relative record number, execute fill sub.
– Did they select a subfile record?
– If so, using the keys from the selected record, retrieve your data base file, do whatever you do…
(This changed the file keys and the relative record number. That’s why you save them.)
– End of loop

Fill subroutine:
Eval a counter to 0 (this is used to fill to the number of records on one page – we’ll pretend it’s 14)
Read with an eof indicator (we’ll use 99)
Dow not *in99 and counter < 14
add 1 to subfile relative rec#
set on subfile dsp indicator
write subfile detail record
add 1 to counter
read with indicator 99
save your last file position keys
save your subfile relative record number
-Normally I never use an indicator on a read. But the indicator 99 is turned on when actual end of file is reached. That will stop the + or *MORE from showing on your subfile at the proper time.)

Great work LeslieL
here’s a site you should check out


Discuss This Question: 6  Replies

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • aceofdelts
    A slight variation I use is to also specify the PAGEUP as well. This only hits if they roll back past the position-to. Program will READP for x records past position-to (x=number of records per screen) or until beginning-of-file. Use that record as an implicit "new position-to" and treat as if user entered that value as a reposition. A bit of a pain but now user can roll thru position-to without a "false" beginning-of-file error. Mike L.
    2,550 pointsBadges:
  • Nutangujar
    Thanks you all... can i use embedded SQL to fetch records....especially how to handle PageUp in SQL...when we generally use ReadP operation.... Thanks, NG
    895 pointsBadges:
  • philpl1jb
    sure you can - here's the link cursor is openned as scrollable Then you can use fetch prior Phil
    54,090 pointsBadges:
  • philpl1jb link was repeated
    54,090 pointsBadges:
  • Nutangujar
    sorry, but i could not access that link -NG
    895 pointsBadges:
  • TomLiotta
    Try this link -- IT Jungle SQL FETCH Options Tom
    125,585 pointsBadges:

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.


Share this item with your network: