IBM i e-Book
A Developer’s Guide to Mastering IBM i Concepts
IBM i Index
Report Program Generator (RPG)
Load All Subfile
In this instance, the SFLSIZ indicates the number of total records can be loaded and SFLPAG indicates number of per page records in subfile.
The maximum value for SFLSIZ can be 9999.
In load all subfile, the system automatically handles PAGEUP and PAGEDOWN.
Usage:
Load all subfile program can be written in RPG, SQLRPG, RPGLE, SQLRPGLE.
We also need to create a display file (DSPF).
Restrictions and compatibility:
It can display maximum of 9999 records to the subfile, if more records need to be display then load all subfile is not compatible.
Code Example:
Physical file – EMPLOYEE
Column Names | Data Type | Length | Decimal | Description |
---|---|---|---|---|
EMPNO | Zoned Decimal | 10 | 0 | EMPLOYEE NUMBER |
EMPNAME | Character | 20 | EMPLOYEE NAME | |
EMPDEPT | Character | 10 | DEPARTMENT | |
EMPMOBNO | Zoned Decimal | 10 | 0 | MOBNO NO |
Display file – EMPLOYEED
In EMPSFL subfile record format, we defined the fields to be populated in the subfile.
In EMPCTL subfile control record format, we defined the required header information or header fields to be populated.
In EMPFTR record format, we defined footer information displayed below the subfile record format.
We used OVERLAY keyword in subfile control record format to overlay EMPFTR record format to the subfile.
In line 13.00, we defined SFLDSP keyword with indicator 51, this will be used in RPG program to display subfile record format.
In line 14.00, we defined SFLDSPCTL keyword with indicator 52, this will be used in RPG program to display subfile control record format.
In line 15.00, we defined SFLCLR keyword with indicator 53, this will be used in RPG program to clear the subfile before loading the subfile.
In line 16.00, we defined SFLEND keyword with indicator 54, this will be used in RPG program to display more if next page is there for the records and display bottom for the last page of subfile records.
RPGLE Program –EMPLOYEER (Free format)
Line 7.00 – decalaration of physical file EMPLOYEE
Line 8.00 – decalaration of display file with subfile record EMPSFL. We used keyword SFILE to reference subfile record relative number (RRN) for the subfile.
In this clearSubfile subroutine, we turned on SFLCLR indicator *IN53 to clear the subfile and writing subfile control record format.
In line 30.00, we initialize the record relative number (RRN) with 0
In this loadSubfile subroutine, we are reading the file EMPLOYEE from top to bottom and writing to subfile record format by increamenting subfile record relative number (RRN).
When SFLEND indicator *IN54 will be turned off, more will be shown at the bottom right of the subfile records.
When SFLEND indicator *IN54 will be turned on, bottom will be shown at the bottom right of the subfile records.
In displaySubfile subroutine, we are displaying the subfile by turning on SFLDSPCTL indicator *IN52.
SFLDSP indicator *IN51 will be turned on if records written to the subfile are greater than 1.
In line 67.00, we are writing the footer record format which will be overlayed to the subfile.
In line 68.00, we are displaying the subfile by using EXFMT keyword which is the combination of keywords WRITE and READ.
When F3 (*IN03) or F12 (*IN12) will be pressed, it will come out from the subfile.
RPGLE Program – EMPLOYEER (Fix format)
Calling program EMPLOYEER, displaying load all subfile with loaded data from physical file EMPLOYEE as shown below –
After pressing pagedown, shown below –