SUBFILES
1
Objectives
To understand the concepts of Subfile programming
2
Prerequisites
Basic knowledge of RPG programming concepts.
3
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.
4
Sub file Display
5
Introduction to Sub files
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 field’s description also identifies its screen location and its display attributes.
6
Introduction to Subfiles (Contd.)
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.
7
Create Subfile
8
Use of Subfiles
Subfiles can be used:
To view the output.
To request for more information about one of the items on the display.
To change one or more of the records.
9
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
Record Formats of a Subfile
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
Subfile Control Record Format
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
Data Description Specifications for a subfile Control-record format
13
Subfile Record Format
The subfile record format declares
Field’s name
Field’s definition.
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
Data Description Specifications for a subfile record format
15
Subfile Keywords
Keywords used:
SFL - identifies the record format as a subfile
SFLCTL - name of the associated subfile
SFLCLR - indicates when the subfile should be cleared
SFLDSPCTL- indicates when to display the subfile control record
16
Subfile Keywords
SFLDSP - indicates when to display the subfile
SFLPAG - indicates the total number of records in a page
SFLSIZ - indicates the number of records the subfile can contain. Maximum – 9999
SFLEND - Displays a plus sign, by default, to indicate when there are more records in subfile. Specify *MORE to display text.
17
Subfile Keywords (Contd.)
SFLFOLD - Specifies the CA or CF key used to fold Multiformat subfile to single line format.
SFLDROP - Initially displays only the first line of the subfile records, and reacts to a function key by switching into a multiline format.
SFLINZ - Initializes all the records in a subfile
SFLNXTCHG- Modifies the subfile record so that it is read on a get-next-changed
operation16
Subfile Keywords (Contd.)
SFLRCDNBR - Specifies which page of the subfile record should be displayed.
SFLCSRRRN - Returns the relative record number of the subfile record on which the
cursor is placed. OVERLAY - Displays the record without first clearing the screen.
ROLLUP - Indicator is set on in the program when the user presses the Roll Up key.
19
Subfile Keywords (Contd.)
ROLLDOWN - Indicator is set on in the program when the user presses the Roll Down 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.
18
Specifying Keywords in Subfile
19
Example of Sub file record formats A R S01 SFL A S1BUSY 13A O 8 28 A S1TENT 13A O 8 44 A S1OUTO 13A O 8 60 A S1UNKN 13A O 8 76 A R C01 SFLCTL(S01) A SFLSIZ(0011) A SFLPAG(0010) A OVERLAY A 27 SFLDSP A 28 SFLDSPCTL A N27 SFLCLR A 29 SFLEND
20
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
LOAD ALL Subfile
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
SINGLE PAGE Subfile
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.
Record Limit is 9999.
Automatic support for ROLLUP but ROLLDOWN key should be handled.
Pages added when the Page down key is pressed are up-dated at the time they are added to the subfile.
24
Example of Expanding Subfile
Handling of page down key
Subfile size 1 greater than subfile page
25
Using Subfile in a program
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
Using Subfile in a program(Contd..)
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
Important Terms used with Subfiles
Relative Record Number(RRN)
A number which associates a file record to the location in the file where the record resides.
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
Top Related