Skip to main content

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) - Used to Specify which page of Subfile Record to be displayed. 

CURSOR or *TOP can be added to this keyword to specify where the cursor needs to be placed. 

A            CSRRRN         4S 0H      SFLRCDNBR(CURSOR)
This would point the cursor at the Subfile Input field. 

A            CSRRRN         4S 0H      SFLRCDNBR(*TOP)
This would point the cursor at the top of page. 

SFLPAG - Used to define the number of records to be displayed on screen per page. 

SFLSIZ - Used to define the total number of records within subfile. Maximum number of records allowed is 9999. 

SFLPAG & SFLSIZ can be used based on the type of Subfile. 
  • Load All Subfile - SFLSIZ can be defined as 9999. And, maximum number of records allowed is 9999.
  • Expandable Subfile - SFLSIZ can be defined with SFLPAG + 1 (E.g.: If SFLSIZ is 8, SFLPAG would be 9).Maximum number of records allowed in Subfile is 9999. 
  • Single Page Subfile - SFLSIZ would be equal to SFLPAG (E.g.: If SFLSIZ is 8, SFLPAG would also be 8). There can be any number of records added to Subfile and this needs to be handled in the program.
SFLCLR - Clears the Subfile. This can be controlled with Indicator and used to Clear the records from Subfile.

A  28                                  SFLCLR

This Indicator needs to be turned ON only to clear the Subfile and needs to be Turned OFF while writing writing the records and displaying the Subfile.


SFLDSP - Used to determine whether Subfile (Data) needs to be displayed or not. 

A  25                                  SFLDSP

This indicator needs to be turned ON only if there is a data in Subfile. And, needs to be turned OFF if there is no data in the subfile or clearing the subfile. 

SFLDSPCTL - Used to determine whether fields in Subfile Control format needs to be displayed or not.

A  26                                  SFLDSPCTL
This indicator needs to be turned ON for displaying the Subfile (even if there is no data) and needs to be turned OFF while clearing the subfile. 

SFLEND - Used to determine end of the Subfile.

A  40                                  SFLEND

By default, Subfile End would be turned OFF and '+' (or More...) sign is displayed at the end of subfile. This needs to be turned ON in the program to mark the End of Subfile and 'Bottom' would be displayed at the end of subfile.

SFLCSRRRN - Returns the RRN of the record where cursor is present. 

A                                      SFLCSRRRN(&SFLCSR)
RRN would be returned to the field defined along with Keyword which can be accessed in the Program.

Comments

Popular posts from this blog

All about READ in RPGLE & Why we use it with SETLL/SETGT?

READ READ is one of the most used Opcodes in RPGLE. As the name suggests main purpose of this Opcode is to read a record from Database file. What are the different READ Opcodes? To list, Below are the five Opcodes.  READ - Read a Record READC - Read Next Changed Record READE - Read Equal Key Record READP - Read Prior Record READPE - Read Prior Equal Record We will see more about each of these later in this article. Before that, We will see a bit about SETLL/SETGT .  SETLL (Set Lower Limit) SETLL accepts Key Fields or Relative Record Number (RRN) as Search Arguments and positions the file at the Corresponding Record (or Next Record if exact match isn't found).  SETGT (Set Greater Than) SETGT accepts Key Fields or Relative Record Number (RRN) as Search Arguments and positions the file at the Next Record (Greater Than the Key value). Syntax: SETLL SEARCH-ARGUMENTS/KEYFIELDS FILENAME SETGT  SEARCH-ARGUMENTS/KEYFIELDS FILENAME One of the below can be passed as Search Arguments. Key Fiel

What we need to know about CHAIN (RPGLE) & How is it different from READ?

CHAIN READ & CHAIN, These are one of the most used (& useful) Opcodes by any RPG developer. These Opcodes are used to read a record from file. So, What's the difference between CHAIN & READ?   CHAIN operation retrieves a record based on the Key specified. It's more like Retrieving Random record from a Database file based on the Key fields.  READ operation reads the record currently pointed to from a Database file. There are multiple Opcodes that start with READ and all are used to read a record but with slight difference. We will see more about different Opcodes and How they are different from each other (and CHAIN) in another article. Few differences to note.  CHAIN requires Key fields to read a record where as READ would read the record currently pointed to (SETLL or SETGT are used to point a Record).  If there are multiple records with the same Key data, CHAIN would return the same record every time. READE can be used to read all the records with the specified Ke

Extract a portion of a Date/Time/Timestamp in RPGLE - IBM i

%SUBDT Extracting Year, Month, Day, Hour, Minutes, Seconds or Milli seconds of a given Date/Time/Timestamp is required most of the times.  This can be extracted easily by using %SUBDT. BIF name looks more similar to %SUBST which is used to extract a portion of string by passing from and two positions of the original string. Instead, We would need to pass a value (i.e., Date, Time or Timestamp ) and Unit (i.e., *YEARS, *MONTHS, *DAYS, *HOURS, *MINUTES, *SECONDS or *MSECONDS) to %SUBDT.  Valid unit should be passed for the type of the value passed. Below are the valid values for each type. Date - *DAYS, *MONTHS, *YEARS Time - *HOURS, *MINUTES, *SECONDS Timestamp - *DAYS, *MONTHS, *YEARS, *HOURS, *MINUTES, *SECONDS, *MSECONDS Syntax: %SUBDT(value : unit { : digits { : decpos} }) Value and Unit are the mandatory arguments.  Digits and Decimal positions are optional and can only be used with *SECONDS for Timestamp. We can either pass the full form for the unit or use the short form. Below i