Your program will hold a flag that indicates which of the hidden fields is currently copied to the display field.
When you load the subfile, format the data for display in your program. Data structures and BIFs such as %EDITC are useful for this. Then store the address data in hidden field 1 and the financial data in hidden field 2. If the flag is set, you are displaying field 1, so copy that to the display field. Otherwise, copy field 2 to the display field.
When the user presses F11, switch the indicator and execute a subroutine to read all the subfile records. For each one read, copy field 2 to the display field and update the subfile record. Then on your next EXFMT the display will magically change.
Keeping the display on the same page is easy, too. The code after the EXFMT (in ILE RPG) is:
C Select Keep RRN C When not *In14 :Empty subfile C Eval CurrPage = *Zero C When CRRN > *Zero :Cursor RRN C Eval CurrPage = CRRN C Other :No cursor RRN C Eval CurrPage = D1DRRN C EndSl In the display file, define (on the SFLCTL format): A SFLCSRRRN(&CRRN) A D1DRRN 4S 0H SFLRCDNBR(CURSOR) A CRRN 5S 0H TEXT('Subfile cursor RRN')So now, in your program, if the subfile has been updated as described, set D1DRRN = CurrPage before the next EXFMT and the same page will be displayed.
MORE INFORMATION ON THIS TOPIC
The Best Web Links: tips, tutorials and more.
Visit the ITKnowledge Exchange and get answers to your developing questions fast.
Ask the Experts yourself: Our application development gurus are waiting to answer your programming questions.
Dig Deeper on iSeries programming commands
Related Q&A from John Blenkinsop
When an error occurs on an IBM command, the diagnostic messages are sent first, then an escape message, which you can monitor. On AS/400 you see the ... Continue Reading
Learn how to 'append data to the file' with the FTP DIR command, and eliminate the hassle of having to end the FTP session and restart to view ... Continue Reading
RPGIV will 'think of' incoming integer fields as binary, and then will redefine them in the program structures as PACKED. So, when you chain a record... Continue Reading