✔ A subfile is a group of records READ from or WRITTEN to a display device file in one single operation.
✔ It is a display file facility
✔ It is a group of records that can be stored in the main memory.
✔ The program can store a group of records in the subfile one by one in a sequence.
✔ LODING SUBFILES:
➢ Load all (Size >Page)
➢ Load on demand (Size >Page) ➢ Load on demand (Size =Page) ✔ Load all (Size >Page)
➢ All the records from the database file will be loaded in to the subfile in one shot.
➢ The subfile size should be greater than the page size at least by one. (SFLSIZ =5, SFLPAG=4). The subfile size will dynamically grow when the subfile size mentioned is less than the number of records in the database file.
➢ PAGEUP and PAGEDOWN are taken care of by the system. ➢ The total subfile size 9999 records.
✔ Load on demand (Size > Page)
➢ The number of records as mentioned in SFLPAG will be loaded initially.
➢ Then the remaining records can be loaded by pressing PAGEDOWN, which is taken care of by the programmer.
➢ Same time PAGEUP is taken care of by the system.
➢ The subfile size should be greater than the page size at least by one. (SFLSIZ =5, SFLPAG=4). The subfile size will dynamically grow when the subfile size mentioned is less than the number of records in the database file.
➢ All the records loaded will exist in the subfile. ➢ The total subfile size 9999 records.
✔ Load on demand (Size = Page)
➢ The number of records that will be loaded into the subfile must always be equal to the value mentioned in for SFLSIZ and SFLPAG. ➢ Every time the subfile should be cleared before paging up or paging
down.
➢ PAGEUP and PAGEDOWN are taken care of the programmer.
➢ The number of records that can be in the subfile at any instance will be equal to SFLSIZ and SFLPAG values.
Subfile points:
Record formats:
One display -1024 records formats One display files –512 subfiles Record formats are
1. Subfile record format (SFL)
2. Subfile control record format (SFLCTL) Subfile record format (SFL)
This record format will have the multiple record definitions -Defining fields.
-Defining database fields.
Subfile Control record format (SFLCTL)
This record format will control the subfile record format. -Defining texts
-Defining control fields. Subfile Size (SFLSIZ)
This keyword can be used to specify the maximum number of records that can be in the subfile (buffer)
Default ->2
Maximum ->9999
Subfile Page (SFLPAG)
This keyword can be used to specify the maximum number of records that can be in one subfile page. That is the maximum number of records that the system will display in the screen at a time.
-Maximum-> depends upon the display record size.
If the subfile size is at least one greater than the subfile page then the subfile size will grow dynamically up to 9999.
General keywords
SFLDSP -> subfile display
SFLDSPCTL -> subfile display control SFLCLR -> subfile clear
SFLEND -> subfile end Define General Keywords
Subfile control record . . . : SENWLT1 Type choices, press Enter. Keyword
Related subfile record . . . SFLCTL SENWND1 Name Subfile cursor relative record . . . SFLCSRRRN Name Subfile mode . . . SFLMODE Name Y=Yes Indicators/+ Display subfile records . . . SFLDSP Y 25 Display control record . . . SFLDSPCTL Y 26 Initialize subfile fields . . . SFLINZ
Delete subfile area . . . SFLDLT
Clear subfile records . . . SFLCLR 28 Indicate more records . . . SFLEND 30 SFLEND parameter . . . *MORE Y
SFLEND parameter . . . *SCRBAR *MORE... Record not active . . . SFLRNA
More... F3=Exit F12=Cancel
This keyword is used to insert the system that the subfile records format has to be displayed. The subfile record format without any record in it cannot be displayed.
Subfile Display control (SFLDSPCTL)
This keyword is used to instruct the system that the subfile control record format has to be displayed.
0009.00 C N30 SETON 2526 Subfile Clear (SFLCLR)
This keyword is used to clear the records in the subfile records format. An indicator can control this keyword.
0005.00 C SETON 28 0006.00 C WRITE SENWLT1
0007.00 C SETOFF 28
Subfile End (SFLEND)
✔ This keyword is used to get the display of ‘+’ sign or a text ‘more’ or ‘bottom’ in the bottom of the subfile.
✔ ‘+ or ‘more’ indicates the existence of more records in the subfile which can be displayed by pressing PAGEDOWN key.
✔ ‘Bottom’ indicates the end of the subfile.
✔ Instead of Enter Key - Help Type a CF or CA key number to specify that the operator is to use the Enter key as a Roll Up key. The specified CF or CA key acts as the Enter key.
Mandatory keywords for subfile ✔ SFL
✔ SFLCTL ✔ SFLSIZ ✔ SFLPAG ✔ SFLDSP
RRN (Relative record number) (control record level keyword)
✔ RRN is the numeric value (1 to 9999) associated with each subfile record for accessing
✔ Each record should have a unique RRN value ✔ This value has to be giving by the program.
✔ This has to be associated with the subfile record format in the F spec continuation line.
✔ This has to be declared in the program as numeric variable of maximum length 4 and decimal position 0.
F spec format in continuation line with SFILE option 0002.00 FSENDESFILECF E WORKSTN
0003.00 F SFILE (SFL01:RRN1 )
Where RRN1 -> RRN variable name SFL01-> subfile record format name.
RPGLE Opcodes EXFMT
If SFLDSP and SFLDSPCTL indicators are on, this opcode will send the two subfile record formats to the display device and waits for the user’s response.
WRITE – (SFL)
➢ This opcode is used to add a record to the subfile record format
➢ RRN value should be set with a non-existing value before adding the record in the subfile record format.
WRITE (SFLCTL)
This keyword is used for clearing & display the subfile SFLDROP (subfile drop)
This control record level keyword is used to assign a CA (command attention) or CF (command function) key. The program first displays the subfile in truncated form; subfile records are truncated to fit on one display line. When the user presses the specified key, the program displays the records in the folded form.
Or
Subfile Initially Truncated - Help Type a command function (CF) or command attention (CA) key number to assign a CF or CA key to specify if a subfile control record requiring more than one display line should be
truncated to one line, or should be folded to display on two lines. When this keyword is specified, the subfile is first displayed in truncated form. The operator presses the specified CF or CA key to switch from truncated form to folded form or from folded form to truncated form.
SFLFOLD (subfile fold)
This control record level keyword is used to assign a CA (command attention) or CF (command function) key. The program first displays the subfile in folded form. When the user presses the specified key, the program displays the records again in the truncated form.
Or
Subfile Initially Folded - Help Type a command function (CF) or command attention (CA) key number to assign a CF or CA key to specify if a subfile control record requiring more than one display line should be truncated to one line, or should be folded to display on two lines. When this keyword is specified, the subfile is first displayed in folded form. The operator presses the specified CF or CA key to switch from folded form to truncated form or from truncated form to folded form.
SFLINZ (subfile initialize)
This control record level keyword is used to specify that the program is to initialize all records in the subfile on the output operation (read & updates) to the subfile control record format.
The fields in each subfile record are initialized to CHAR->BLANKS
NUME->ZEROS FLOAT->NULLS
SFLNXTCHG (subfile next change)
This record level keyword is used on the subfile control record format to force the user to correct program-detected keying error in the subfile records that have been read by the program. It does this by causing the record to be changed so that a get-next-changed operation must read the record.
Or
Return Record - Help Type Y (Yes) to instruct the system to return this subfile record to your program on a subsequent Get-Next-Changed input operation to the subfile. This record is returned whether or not the operator changes it. Note: You must type Y. If you do not, the entry will not be used. `You can specify condition indicators for the SFLNXTCHG keyword.
SFLROLVAL (subfile roll value)
This field-level keyword is used to specify that the user can key a value into this field to tell the program how many records to PAGEUP or PAGEDOWN when the appropriate paging key is pressed.
SFLRCDNBR (subfile record number)
This field level keyword on the subfile control record format is used to specify that the page of the subfile to be displayed is the page containing the record whose relative record is in this field. If you do not specify this
keyword, the program displays the first page of the subfile by default
Example for load all
SKANDASAMO/SUBFILE NEWEMP
*************** Beginning of data ******************* 0001.00 UNIQUE
0002.00 R EMPNEW
0003.00 EMPNOM 6P 0 TEXT('EMPLOYEE NUMBER') 0004.00 EMPNA 15A TEXT('EMPLOYEE NAME') 0005.00 SEX3 1A TEXT('EMPLOYEE SEX') 0006.00 AGE3 3P 0 TEXT('EMPLOYEE AGE') 0007.00 ADDRESS5 15A TEXT('ADDRESS') 0008.00 CITY5 10A TEXT('CITY')
0009.00 K EMPNOM
****************** End of data ********************************* DATA FILE
Display Report
000001 101 K.SENTHILKUMAR M 25 ATTUR SALEM 000002 102 R.SHYAMSUNDAR M 27 TRICHY TRICHY 000003 103 B.MOHAN M 27 TCODE SALEM 000004 104 K.KUMAR M 25 SALEM SALEM 000005 105 A.ARUL M 25 SALEM NAMAKKAL 000006 106 BALU M 25 SALEM SALEM 000007 107 SENTHIL M 35 SALEM TRICHY 000008 108 RAJ M 22 TCODWE SALEM 000009 109 HEMA M 33 SALEM CHENNAI 000010 110 VEL M 67 SALEM SALEM 000011 111 RAMESH M 56 ATTUR SALEM 000012 122 SUDHA M 28 SALEM ATTUR 000013 123 KANDASAMY M 34 SALEM ATTUR ****** ******** End of report ********
SKANDASAMO/SUBFILE SUB04 *************** Beginning of data **************************** 0002.00 FSENDESFILECF E WORKSTN
0015.00 C *IN03 DOWEQ *OFF 0016.00 C EXFMT MAIN1
0016.01 C IF *IN04=*ON AND EMPCUR='EMPNOM' 0016.02 C CALL 'SELOADALL3'
0016.03 C ENDIF 0017.00 C 03 LEAVE 0018.00 C ENDDO
0019.00 C SETON LR ****************** End of data ******************************* SKANDASAMO/SUBFILE SELOADALL3 *************** Beginning of data ***************************** 0001.00 FNEWEMP IF E DISK 0002.00 FSENDESFILECF E WORKSTN 0003.00 F SFILE(SENWND1:RRN1) 0004.00 C Z-ADD 1 RRN1 4 0 0005.00 C SETON 28 0006.00 C WRITE SENWLT1 0007.00 C SETOFF 28 0008.00 C READ EMPNEW 30 0009.00 C N30 SETON 2526 0010.00 C DOW *IN30=*OFF 0011.00 C WRITE SENWND1 0012.00 C ADD 1 RRN1 0013.00 C READ EMPNEW 30 0014.00 C 30 LEAVE 0015.00 C ENDDO 0016.00 C DOW *IN03=*OFF 0016.01 C 03 LEAVE 0016.02 C* WRITE HEATER 0016.03 C* WRITE FOOTER1 0016.04 C EXFMT SENWLT1
0020.00 C ENDDO
0021.00 C SETON LR
****************** End of data ***************************** window main1 take 8
Select Record Keywords Record . . . : MAIN1
Type choices, press Enter. Y=Yes General keywords . . . Y Indicator keywords . . . Y Application help . . . .
Select General Keywords Record . . . : MAIN1
Type choices, press Enter. Keyword Y=Yes If this record is not on display, write it
to the display before issuing read . . . INZRCD Keep record on display . . . KEEP
Assume record is on display . . . ASSUME Y Allow rolling of lines . . . ALWROL
Retain CLEAR HELP HOME and ROLL keys . . . RETKEY
Retain command function (CFnn and CAnn) keys . . . RETCMDKEY Change input defaults . . . CHGINPDFT
Menu-Bar display . . . MNUBARDSP Select parameters . . . .
Entry field attribute . . . ENTFLDATR Select parameters . . . .
Return cursor location . . . RTNCSRLOC Y Select parameters . . . .
Define Return Cursor Location Record . . . : MAIN1
Keyword number Roll 1 of 1 Y +/- F4 for list Type parameters, press Enter.
Keyword
Return cursor location . . . RTNCSRLOC Y Y=Yes Type indicator *RECNAME . . . Y Y=Yes Cursor record . . . RECSD Name Cursor field . . . EMPCUR Name Cursor position . . . Name CF03 03
CF04 04
TAKE 12 AND F4
Work with Fields Record . . . : MAIN1
Number of fields to roll . . . 6 Type options, change values, press Enter.
1=Select keywords 4=Delete field
Option Order Field Type Use Length Row/Col Ref Condition Overlap 70 AGE C 21 15 014 80 RECSD A H 10 90 EMPCUR A H 10 100 --- C 76 21 003 110 F3->EXIT C 37 22 005 120 EMPNOM S B 6,0 09 036 Y More... Add H Hidden Add M Message Add P Program-to-system TAKE 12 SENWLT1
Select Window Keywords Window record . . . : SENWLT1 Type choices, press Enter.
Y=Yes General keywords . . . Y Select record keywords . . . Y General SFLCTL keywords . . . Y Subfile display layout . . . Y
Subfile messages . . . Y
Select General Keywords Window record . . . : SENWLT1 Type choices, press Enter.
Keyword Y=Yes Indicators/+ Window parameters . . . WINDOW Y
Select parameters . . . Y Window borders . . . WDWBORDER Select parameters . . . .
Remove windows . . . RMVWDW User Restore Display . . . USRRSTDSP Define Window Parameters Record . . . : SENWLT1
Keyword . . : WINDOW
Referenced window . . . Name -OR-
Window definition
Default start positioning . . . Y=Yes -OR-
Start line
Program-to-system field . . . Name Actual line . . . 2 1-25
Start position
Program-to-system field . . . Name Actual position . . . 2 1-128
Window lines . . . 20 1-25 Window position . . . 40 1-128 Message line . . . Y Y=Yes Restrict cursor to window . . . Y Y=Yes Select Record Keywords
Record . . . : SENWLT1 Type choices, press Enter. Y=Yes General keywords . . . Y Indicator keywords . . . Y Application help . . . . Help keywords . . . . Output keywords . . . . CF12 12 CF03 03
Define General Keywords Subfile control record . . . : SENWLT1 Type choices, press Enter. Keyword Related subfile record . . . SFLCTL SENWND1 Name Subfile cursor relative record . . . SFLCSRRRN Name Subfile mode . . . SFLMODE Name Y=Yes Indicators/+ Display subfile records . . . SFLDSP Y 25
Initialize subfile fields . . . SFLINZ Delete subfile area . . . SFLDLT
Clear subfile records . . . SFLCLR 28 Indicate more records . . . SFLEND 30 SFLEND parameter . . . *MORE Y
SFLEND parameter . . . *SCRBAR *MORE ... Record not active . . . SFLRNA
More... F3=Exit F12=Cancel
Define Display Layout Subfile control record . . . : SENWLT1 Type values, press Enter.
Keyword Number Records in subfile . . . SFLSIZ 6 Program-to-system field . . . .
Records per display . . . SFLPAG 5 Spaces between records . . . SFLLIN
OUTPUT
EMPLOYEE DETAILS 1.SELECT
OPT EMPNUMBER NAME 000101 K.SENTHILKUMAR 000102 R.SHYAMSUNDAR 000103 B.MOHAN
000105 A.ARUL More... EMPLOYEE DETAILS: 1.SELECT
OPT EMPNUMBER NAME 000106 BALU 000107 SENTHIL 000108 RAJ 000109 HEMA 000110 VEL More... EMPLOYEE DETAILS 1.SELECT
OPT EMPNUMBER NAME 000111 RAMESH 000122 SUDHA
123 KANDASAMY