IBM i

IBM i 

A space for professionals working with IBM’s integrated OS for Power systems to exchange ideas, ask questions, and share expertise on topics like RPG and COBOL development, application modernization, open source integration, system administration, and business continuity.


#Power


#IBMi
#Power
 View Only

Basic Understanding Subfiles in IBM i

By Pavan Thute posted 2 days ago

  

Understanding Subfiles in IBM i

When working with IBM i (AS/400) applications, subfiles are one of the most powerful features for building interactive screens. They allow developers to display multiple records in a single format area, making data navigation and manipulation easier.

What is a Subfile?

A subfile is a collection of records displayed on a screen using a single record format. Instead of defining multiple formats for each record, subfiles let you reuse one format for multiple rows, improving efficiency and consistency.

Parts of a Subfile

A typical subfile consists of:

1. Subfile Control Record Format – Handles overall control (e.g., headings, messages, page navigation).

2. Subfile Data Part – Area where the actual records loaded into the subfile.

3. Footer Part : It shows functions keys like F3=Exit

Types of Subfiles

IBM i supports different subfile types based on usage:

·        Load-All Subfile: Loads all records at once. Best for small datasets.

·        Expanded Subfile: Load as per user requirement.

·        Single-Page Subfile: Loads only one page at a time. Ideal for large datasets.

Common operations include:

·        Load Subfile: Populating the subfile with records using WRITE operations.

·        Clear Subfile: Removing all records using CLEAR or by writing blanks.

·        Initialize Subfile: Modifying specific records in the subfile.

·        Display Subfile: Showing the subfile on the screen using EXFMT.

·        READC in Subfile

Important Keywords:

SFLDSP – Controls whether the subfile records are displayed on the screen.

SFLDSPCTL – Controls whether the subfile control record format is displayed.

SFLCLR – Clears all records from the subfile before loading new data.

SFLEND – Indicates the last record in the subfile (used for scrolling logic).

SLFINZ – Initializes subfile records with default values when created.

SLINXTCHG – Marks the next changed record in the subfile for update processing.

SFLSEL – Allows record selection (e.g., option field).

SFLRCDNBR – Specifies relative record number for positioning.

How to read data part of subfile?

READC stands for Read Changed.
It is an RPG operation code used to read only those subfile records that have been changed by the user during interaction with a display file.

Efficiently process user updates without reading all subfile records.

Commonly used in update subfiles where users modify multiple rows.

When a subfile record is changed, the system sets the change indicator for that record.

READC reads the next changed record from the subfile.

If no more changed records exist, the end-of-subfile indicator is set.

If you get yourself familiar with all these concepts as mentioned above —it means you truly understand how subfiles work in IBM i. This knowledge is essential for building robust, user-friendly interactive applications.

1 comment
9 views

Permalink

Comments

yesterday

good article on basics of subfiles. !