|
Hi Amitava,There are two fields you need to worry about when maintaining position within a subfile:
1) The field you define as SFLRCDNBR - when you populate this field the OS will attempt to display the subfile page which contains the row with this RRN. You would usually set this to 1 when first displaying your subfile. This forces display of the first page. A common error is to use your RRN field as the SFLRCDNBR field - this usually results in your subfile displaying the last page built because SFLRCDNBR contains the RRN of the last row you wrote. Another common error is to never update this value as you navigate through the subfile - this results in you always going back to the first page whenever you press enter (as page 1 contains row 1).
2) Within the file information data structure for your display file is a field which contains the RRN of top row of the currently displayed page. This field is in positions 378-379 and is a binary field.
So, to maintain position - immediately after you display your subfile page save the RRN of the top row in your SFLRCDNBR field. This forces the OS to re-display the current page when you press Enter. That's it!
You can take this further - when validating subfile entries you can place the RRN of the row in error into the SFLRCDNBR field and the OS will automatically take you to the page containing the row in error next time the subfile is displayed. This allows the user to enter details on many pages - you will simply take them to the errors as you validate.
For simple position maintenance you need to use the following code: F-spec: FYourFile cf e workstn infds(dspinf) D-Spec: * INFDS for display file... Ddspinf DS D Sfl_rrn 376 377I 0 D Sfl_top 378 379I 0 C-Spec: C Exfmt CTL1 * Maintain subfile position... C If Sfl_top > 0 C Eval F01pos = Sfl_top C EndifNote: Only populate your SFLRCDNBR field (F01pos above) with a value greater than 0 or the display will error next time the subfile is displayed. (I have discovered that if you use ERRMSGID in the DDS to validate control format fields the infds is cleared when the error is issued - this results in the infds sfl_top field being set to zero. As a result the display errors when displaying the next time after an error was issued)
HTH Larry Ducie
As an Amazon Associate we earn from qualifying purchases.
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.