× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi Marvin,

<snip>
So I guess you have to read the subfile record in order for the subfile to be displayed at the proper position. Go figure.
</snip>

This isn't true.

There are three fields that you use to successfully maintain position within a subfile: 1) The relative record number. This field is used to hold your CURRENT position within the subfile. It is incremented by you during your subfile build, and updated by the system whenever you access a subfile record. [defined using the sfile(format : SFLRRN) keyword within your program]. We shall call this field SFLRRN. 2) The subfile record number. This field contains the subfile record you want to the system to display the next time the subfile is written to the screen. By populating this you are telling the system to display the page which contains the subfile record with a SFLRRN equal to this value. [ defined using the SFLRCDNBR keyword within your DDS]. We shall call this field SFLPOS. 3) The Subfile Top record number. This field contains the RRN of the top subfile record on the currently displayed page. [ defined within the INFDS of the display file in positions 378 -379] We shall call this field SFLTOP. (if you disply multiple subfiles this values is not useful and you need to use SFLCSRRRN).

When you build your subfile you increment SFLRRN prior to each write - ensuring a unique value for each record. When you display your subfile for the first time you set SFLPOS to 1. This ensures you display the first page (as it contains the first subfile record). Immediately after the EXFMT you save SFLTOP into SFLPOS. This ensures that you will stay on the same page. You're telling the system to position to the page which contains the subfile record at the top of your current page. Thus, you don't move! If you allow the users to enter data into multiple subfile records accross many pages then you can position to erroneous entries as you validate - simply put the RRN of the record you're validating into SFLPOS and redisplay the screen. Voila! you're positioned to the page which contains the error. If the user fixes the error and presses Enter then they'll either move to the next error or stay on the same page.

All you need to do is:
1) Set SFLRRN = 0.
2) Build your subfile.
3) At this point SFLRRN = number of subfile records, you should set SFLPOS = 1, SFLTOP is set by the system and is currently undefined. 4) EXFMT - the page containing SFLRRN = SFLPOS = 1 is displayed - the first page. 5) Immediately after the EXFMT place SFLTOP into SFLPOS (this ensures you default to staying on the current page)
6) Do something exciting in your code...
i) If you want to position to (and display) an invalid subfile line which you're working on put SFLRRN into SFLPOS and redisplay. ii) If you want to osition to (and display) any subfile record - read through the subfile, select the record based on your search/positioning criteria, and place SFLRRN into SFLPOS. iii) If you want to simply maintain position then do nothing - you always default to this by putting SFLTOP into SFLPOS after the EXFMT.

Basically, if you want to position to ANYWHERE within your subfile simply place the RRN of the record you want into SFLPOS. The special case is when you want to stay where you are - here you use SFLTOP.

That's it. I've never had any subfile positioning issues using this - and I use SFLFOLD/SFLDROP on most screens.

Note: to maintain position within the subfile using SFLTOP and SFLPOS I didn't need to chain to ANY subfile records - I simply used the two fields the system provides for this purpose.

Finally, NEVER use the same field for your relative record number (SFLRRN) and your subfile record number (SFLPOS) as this will only lead to confusion and the need for extra save variables to "hold the current subfile size" or to "hold your current position", etc..

HTH

Larry Ducie



As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.