Subfile Synchronization

RPG
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

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


Subfile Synchronization

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 
BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  •  

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: