Let’s look at the differences between these IBM i (previous generations of this machine include the AS400 and iSeries) subfile-related keywords:
- SFLDSP (Subfile Display):
- This keyword is used at the record level to display the subfile.
- It works in conjunction with option indicators to control the display.
- If there are no records to display in the subfile, turning off this indicator prevents the subfile from being displayed, avoiding session or device errors.
- SFLDSPCTL (Subfile Display Control):
- This keyword is required when your program sends an input operation to the subfile-control record format.
- It defines how the subfile can be displayed, cleared, deleted, and initialized.
- Essentially, it controls the behavior of the subfile display.
- SFLINZ (Subfile Initialize):
- Use this record-level keyword on the subfile-control record format.
- It specifies that the IBM i operating system initializes all records in the subfile on an output operation to the subfile-control record format identified by the SFLCTL keyword.
- Fields in each subfile record are initialized based on their data types (e.g., blanks for character fields, nulls for floating-point fields, zeros for numeric fields).
- After initialization, all records in the subfile are considered active but not changed until the user modifies them or your program sends an output operation with the SFLNXTCHG keyword.
- SFLCLR (Subfile Clear):
- This optional keyword is used to clear the subfile.
- When specified, it clears all records in the subfile.
- Useful when you want to reset the subfile before adding new records.
- SFLSIZ (Subfile Size):
- Specifies the maximum number of records that can be displayed in the subfile.
- It determines the size of the subfile buffer.
- If the subfile size equals the subfile page size, certain keywords (like SFLCLR) are ignored.
- SFLPAG (Subfile Page):
- Specifies the number of records displayed per page.
- Helps manage scrolling through the subfile.
- If SFLPAG equals SFLSIZ, some keywords are ignored.
In summary, SFLDSP controls display behavior, SFLINZ initializes records, SFLCLR clears the subfile, SFLSIZ defines the maximum size, and SFLPAG determines the page size. Each keyword serves a specific purpose in managing subfiles within your IBM i applications.