Use of Subfiles

Some typical ways you can make use of subfiles include:
  • Display only. The work-station user reviews the display.
  • Display with selection. The user requests more information about one of the items on the display.
  • Modification. The user changes one or more of the records.
  • Input only, with no validity checking. A subfile is used for a data entry function.
  • Input only, with validity checking. A subfile is used for a data entry function, but the records are checked.
  • Combination of tasks. A subfile can be used as a display with modification, plus the input of new records.

The following figure shows an example of data description specifications for a subfile control-record format. For an example of using a subfile in an RPG program, see Search by Zip Code.

Figure 1. Data Description Specifications for a Subfile Control-Record Format
*.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ..*
AAN01N02N03T.Name++++++RLen++TDpBLinPosFunctions++++++++++++++++++++*
A          R FILCTL                    SFLCTL(SUBFIL)
A N70                                  SFLCLR
A  70                                  SFLDSPCTL
A  71                                  SFLDSP
A                                      SFLSIZ(15)
A                                      SFLPAG(15)
A                                      TEXT('Subfile Control Record')
A                                      OVERLAY
A  71                                  ROLLUP(97 'Continue Search')
A                                      CA01(98 'End of Program')
A                                      HELP(99 'Help Key')
A                                  1  2'Customer Name Search'
A                                  3  2'Search Code'
A            SRHCOD   R         I  3 14PUTRETAIN
A                                  5  2'Number'
A                                  5 10'Name'
A                                  5 32'Address'
A                                  5 54'City'
A                                  5 76'State'
A*
The subfile control-record format defines the attributes of the subfile, the search input field, constants, and function keys. The keywords you can use indicate the following:
  • SFLCTL names the associated subfile (SUBFIL).
  • SFLCLR indicates when the subfile should be cleared (when indicator 70 is off).
  • SFLDSPCTL indicates when to display the subfile control record (when indicator 70 is on).
  • SFLDSP indicates when to display the subfile (when indicator 71 is on).
  • SFLSIZ indicates the total number of records to be included in the subfile (15).
  • SFLPAG indicates the total number of records in a page (15).
  • ROLLUP indicates that indicator 97 is set on in the program when the user presses the Roll Up key.
  • HELP allows the user to press the Help key for a displayed message that describes the valid function keys.
  • PUTRETAIN allows the value that is entered in the SRHCOD field to be kept in the display.

In addition to the control information, the subfile control-record format also defines the constants to be used as column headings for the subfile record format.