You are on page 1of 2

SUBFILES

What is a subfile? Subfile is a group of records that have the same record format . They are read from and written to a display station in one operation. A subfile is not a file, rather it is a temporary place to store data of the same format to be used by a display file program. Why use subfiles? When you want to display multiple like records on a display Programmer will have control to decide how many records he wants to display allowing through scroll or page Add/Update/delete from data files very effectively. Subfiles can be used to create self-extending data structures and arrays in RPG program. What is the difference between Data structures, Arrays and Subfiles data structures and arrays? Subfiles datastructures and arrays dynamically expand as your data expands where as normal data structures and arrays cannot grow dynamically. What is DDS? Data Definition Specifications (DDS) . Subfiles programs are easy to write and maintain because much of the work is done in DDS. What is SFL and SFLCTL? SFL: Subfile record format SFLCTL: Subfile control record format What does SFL contains? Fields Definition and Attributes of those fields Actual data

Subfile record format is used in memory and only for the duration of the job. SFL keyword is used in DDS. RECORD keyword is used in Physical file. What does SFLCTL contains? Subfile control record format is used to describe the heading information for the subfile. SIZE of the file Conditions underwhich the subfile will be cleared, initialized, displayed and ended.

What are the four keywords required in the subfile control record format ? SFLCTL subfile control record format same as RECORD keyword does for physical files. SFLSIZ Initial number of records the subfile may contain. SFLPAG number of records that one screen of data may contain SFLDSP When the subfile is displayed. SFL record format must immediately precede the SFLCTL format. The individual keywords available in each format can be placed in any order, but they must exist at the top of the format, before any constant or field definitions.

How should I use SUBFILE in RPG program? Code SUBFILE program Compile it Use it in the RPG program Initialize,load and display your sub file. What is SFLCLR keyword? SFLCLR: To clear a subfile. This removes all records from the subfile. SFLINZ: Subfile initialize which will set all the records in the subfile to their default value. How to load SUBFILE? 1. Retrieve data from one or more data files and write that data to the subfile record format using RPG write operation. 2. Load your subfile is to initialize the subfile using SFLINZ, dipslay the subfile with its default values to the screen, and allow the user to type data into the subfile from the screen.

You might also like