Midrange News for the IBM i Community


Posted by: rpgprogrammer
Vancouver, BC
Subfile - Page Equal
has no ratings.
Published: 24 Sep 2013
Revised: 25 Sep 2013 - 1277 days ago
Last viewed on: 24 Mar 2017 (2207 views) 

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

Subfile - Page Equal Published by: rpgprogrammer on 24 Sep 2013 view comments(2)

Hi, I have more then 9999 records so would have to use Page equal subfile. But this subfile I have to create is maintainable. user can select the options on VDU to select records and do change maintenance. What I heard is when user select one record on first page and then do page down and select second record from page 2, and again do page up, the 1st select record on page one is lost as subfile is re-loaded.. Can some one throw light on this or if some one has some sample code would be gr8. Thanks

Return to midrangenews.com home page.
Sort Ascend | Descend

COMMENTS

(Sign in to Post a Comment)
Posted by: DaleB
Premium member *
Reading, PA
Comment on: Subfile - Page Equal
Posted: 3 years 6 months 4 hours 17 minutes ago

If I understand correctly, you're going to need to keep track of it yourself. As you're paging through the table, you only see one page of records at a time in the subfile. When you page down or up, you need to read the subfile rows, and store any changes, including non-database fields such as an Opt field, then load the next or previous page.

I probably wouldn't write every subfile record to the temp storage area, only those that have changes. As you load each page, you'll want to check your storage area to see if your record is already there. Then either load form the temp storage, or go get the info from the database.

The form of the temp storage area is up to you. Could be a temp table, an array DS, or something else which you're comfortable with. Don't forget to include all subfile fields, including Opt columns and such, so that you can restore them if you happen to page back to that record.

Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: Subfile - Page Equal
Posted: 3 years 6 months 1 hours 59 minutes ago
Edited: Wed, 25 Sep, 2013 at 14:50:36 (1277 days ago)

As Dale suggested, my way is to use a Data Structure with the DIM(15000) keyword on it to set it to the number of entries you could have. I then map it to a point to a User Space--which gives me the 16MB size with auto-grow features. Then I use the SORTA %SUBARR( mySubFile : 1 : n ) where "n" is the current number of elements.

I normally use LIKEREC(mySFL:*ALL) when defining the DS to make sure its the same as the correspending Subfile.

Then as you page through it a page at a time, you simply increament the page number to the PGNBR * PGSIZE and you have the array element of the top-most subfile entry.

As they roll throught he subfile, you set the OPT (or OPTION) subfield to their option/choice and save it. F5=Refresh clears that entry.

One other method, would be to create an SQL Cursor as a SCROLLING CURSOR and then just roll back and forth through the records--but that option doesn't give you an integrated way to save the OPT/OPTION value.