Do you have a program that uses multiple subfiles? Do you want to keep the records in all of the subfiles synchronized? I have a simple technique to solve the problem.
Suppose you have a program that presents three views of a list of customer records-phone number, billing address, and shipping address. Each view is displayed through a different subfile. The program allows the user to rotate through the three different views by pressing a function key. If the user pages forward on the phone numbers view and then requests the billing address view, you want the program to display the same group of records that were displayed on the phone number view. If the user requests the shipping address view, you also want the same group of records to appear.
My technique uses the relative-record number (RRN) of the last subfile displayed. This RRN can be obtained through the File Information Data Structure (INFDS) in positions 378-379. In the example, whenever F11 is pressed, a counter called SCREEN increments. By placing the last RRN of the last display in the Subfile Record Number (SFLRCDNBR) field, the subfile records stay synchronized. (Make sure that the SFLRCDNBR field has a value when the subfile is first displayed. Otherwise, the program will issue a device error for trying to write a record with an RRN value of 0.) The last subfile displayed moves its value into the first subfile, so the view starts from the beginning again. The SCREEN field is also reset to 0.
4 contains DDS and RPG code segments for this technique.
Figure 4 contains DDS and RPG code segments for this technique.
- Michael Veit
Figure 4 DDS and RPG Code Segments for Subfile Synchronizat
DDS Required in Each Subfile Record *. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 * * Subfile A's hidden field for subfile record positioning * A REC01 4S 0H SFLRCDNBR(CURSOR) * * Subfile B's hidden field for subfile record positioning * A REC02 4S 0H SFLRCDNBR(CURSOR) * * Subfile C's hidden field for subfile record positioning * A REC03 4S 0H SFLRCDNBR(CURSOR) RPG Required to Synchronize Multiple Subfiles Records * * Relative record number of the lowest subfile record number * displayed on page * *. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 IWSDS DS I B 378 3790RTNRRN * * F11 changes view (controls which subfile is displayed) C *IN11 IFEQ *ON C ADD 1 SCREEN C ENDIF * C SELEC * C SCREEN WHEQ 1 C EXFMTSUBFA C Z-ADDRTNRRN REC02 * C SCREEN WHEQ 2 C EXFMTSUBFB C Z-ADDRTNRRN REC03 * C SCREEN WHEQ 3 C EXFMTSUBFC C Z-ADDRTNRRN REC01 C Z-ADD0 SCREEN * C ENDSL *. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7