Sub Files
Sub Files
Objectives
Prerequisites
Course Outline
The concepts of subfiles Subfile Record Formats Subfile Control-Record Formats Types of Subfiles Subfile design using SDA. Subfile Processing Subfile validation and database updates. Addition and Modification Program Update and Delete Program Coding a message subfile.
A group of records that have the same record format and are read from and written to a display station in one operation. A subfile differs from other physical files in the following ways:
It is temporary, existing only until the RPG program that creates and owns it ends. Within a subfile, each fields description also identifies its screen location and its display attributes.
6
Subfile is displayed a page at a time. Number of records in a subfile must also be specified in the DDS.
One display file can contain more than one subfile, and up to 12 subfiles can be active concurrently.
Create Subfile
Use of Subfiles
To view the output. To request for more information about one of the
items on the display.
Use of Subfiles(Contd..)
To input data with no validity checking To input data with validity checking Combination of display with modification and the
input of new records.
10
Records in a subfile are specified in the DDS for the file. A Subfile has 2 record formats: Subfile Control Record Format Subfile Record Format The subfile record format must precede the subfile control record format. Footer record is optional to create a subfile display. If used, definition of the function keys is given here.
11
Defines the attributes of the subfile, the search input field, constants, and function keys. Defines the constants to be used as column headings for the subfile record format.
12
13
Field definitions can either be specified explicitly or by reference to a field definition in a physical file Handles the physical read, write, or control operations of a subfile
14
15
Subfile Keywords
Keywords used:
- identifies the record format as a subfile - name of the associated subfile - indicates when the subfile should be cleared
Subfile Keywords
SFLDSP SFLPAG
- indicates when to display the subfile - indicates the total number of records in a page
SFLSIZ
SFLEND
- indicates the number of records the subfile can contain. Maximum 9999
- Displays a plus sign, by default, to indicate when there are more records in subfile. Specify *MORE to display text.
17
SFLDROP
SFLINZ
OVERLAY
- Displays the record without first clearing the screen. - Indicator is set on in the program when the user19presses the Roll Up key.
ROLLUP
HELP
- Allows the user to press the Help key for a displayed message that describes the valid function keys.
18
19
20
A 29
SFLEND
Types of Subfiles
Load All Subfile Loads all records of the file into a large subfile before displaying the first screen Single Page Subfile Loads a single page of records and displays the subfile Expanding Subfile Loads the records to fill a single page and displays the subfile
21
SFLSIZ value should be one more than SFLPAG value. Record Limit is 9999. Automatic support for ROLLUP and ROLLDOWN keys. User has to wait until entire file is loaded. Data is only updated when the subfile is reloaded. Changes made to the data after the subfile is loaded will not be apparent. 22
Replaces the page with the next/previous page of data. Subfile size(SFLSIZ) value is equal to SFLPAG. Both ROLLUP & ROLLDOWN keys should be handled. Preferred for working with dynamic data. Uses least memory. No limit to the number of records.
23
EXPANDING Subfile
Adds a page at a time to the subfile. SFLSIZ value should be one more than the subfile page(SFLPAG) value.
25
To use a subfile the following basic operations should be performed in the high level language program
Initialize the subfile by reading records from database file and writing them to subfile. Send subfile to the display in one output operation using subfile control record format.
26
After the user reviews the records, changes them, or enters new records) read the subfile control record format Process each record in subfile individually, updating the database file or writing new records to the database file as required.
26
READC Operation
An RPG opcode strictly used with subfiles. It returns the next changed subfile record to the
program.
27
Summary
The concepts of subfiles Subfile Record Formats Subfile Control-Record Formats Types of Subfiles Subfile design using SDA. Subfile Processing Subfile validation and database updates. Addition and Modification Program Update and Delete Program Coding a message subfile.
31
Thank You