Skip to main content


Showing posts from May, 2020

Subfile Keywords in IBM i

Subfile Keywords: Subfiles are one of the important concepts on IBM i and widely used. Below are some of the Keywords used in Subfiles.  SFLNXTCHG (Subfile Next Change) - Used to mark the Subfile record as Modified. So that this record can be read using READC (Read Changed Record) operation in the Program. This needs to be defined in Subfile data format.  This can be used by defining Indicator against this Keyword or without defining any Indicator. Using Indicator would help programmer control the operation in the Program. Without the indicator, every record would be marked as Modified by default and READC would read every record. Click Here  to see more about SFLNXTCHG & READC. E.g.: A  50                                  SFLNXTCHG In this example, Indicator '50' can be used to control the SFLNXTCHG. Turning ON the Indicator '50' and Updating the Subfile record would modify the Subfile record allowing it to be read using READC.    SFLRCDNBR (Subfile Record Number)

RGZPFM Usage & Important Parameters

Reorganize Physical File Member (RGZPFM): RGZPFM command is used to remove the deleted records from Physical file member and reorganizes the member. Some of the Key points to remember. Only one member can be Reorganized at a time. Key file can be mentioned (either Physical File or Logical File with Key fields) to Reorganize the data with Keyed Sequence. Rebuild Access Path for the Physical file and associated logical files. This can be done either Synchronously or Asynchronously to help save the time and/or improve performance. Below are some of the key parameters to note.  FILE - Name of Physical File MBR - Name of the Physical File Member to be Reorganized. Defaults to '*FIRST', Member Name can be entered. KEYFILE - Used to specify whether file needs to be Reorganized and Key File to be used to Reorganize records. Below are the possible values for this parameter.  *NONE (Default) - No Reorganization will happen and Deleted records will be removed from the Member. *RPLDLTRC

Usage of OVRDBF & OPNQRYF - Explained

OVRDBF: OVRDBF (Override Database file) comes handy in some scenarios where,  Override the file (or Specific Member) named in the Program. This can be used to Override a file to point to the file in Specific library.  E.g.: FILE1 is present in both LIB1 & LIB2 and LIB1 is on top of the library list, Required file name and Library can be mentioned in TOFILE Keyword.  This can be achieved using EXTFILE keyword on F-SPEC in RPGLE. Or, to access the file with the different name. E.g.: If FILE1 & FILE2 are of same format and we need to use the file based on specific criteria in the Program, Required file name can be mentioned in TOFILE Keyword and File name to be used in FILE Keyword. This can be achieved using EXTFILE with Variable specified (with required file name populated in run time) and USROPN on F-SPEC in RPGLE. Access specific Member of file in case of Multi Member files. E.g.: If FILE1 has multiple members (MBR1, MBR2, etc...), This can be done by specifying the member nam

Load All Subfile - Full Free Format RPGLE

Load All Subfile in Full Free Format RPGLE Earlier in my post I shared a simple Load All Subfile in RPGLE. Click Here for this post and for more details on Subfile. In this post, we will use the same Example using Full Free Format RPGLE. Refer this link  for the Sample Physical file and Display File used in this Article. Below is the Sample RPGLE code for Load All Subfile. **Free   // Define Physical File   Dcl-F TESTFILE ;   // Define Subfile   Dcl-F TESTSUBFIL WORKSTN SFILE ( SFDTAR : SFRRN ) ;   // Define Required Variables   // Main Process   ExSr Sub_Init ;   ExSr Sub_Main ;   ExSr Sub_Exit ;   // Sub_Init - First time initialization routine   BegSr Sub_Init ;     SFPGMNAM = 'TESTLODALL'     // Clear Subfile     *In25 = *Off ;     *In26 = *Off ;     *In28 = *On ;     Write SFCTLR ;     *In28 = *Off ;     *In25 = *On ;     *In26 = *On ;    EndSr ;    // Sub_Main - Main Processing Routine    BegSr Sub_Main ;      ExSr Sub_Load ;      Dow *In03 = *