Professional Documents
Culture Documents
Module - 6
Objectives
What are Subfiles?
Why Use Subfiles?
Basic Subfile Concepts
Types of Subfiles
Subfile Formats
Subfile Keywords
Multiple Subfiles
Input and Update Subfiles
Equal Subfiles Vs Expanding Vs Loadall Subfiles
Limitations
2
File
1
Subfile Format
File
2
Subfile Record
Subfile Record
File
Subfile Record
Subfile Record
Display
Subfile Record
Screen
5
Loading a Subfile
Loading a Subfile : You place records into the subfile format with a process known
as loading. During the loading process, you read one or more database files to
extract information. You then write this information in the form of subfile
records to the subfile format.
DATABASE FILES
File
1
Subfile Format
File
Subfile Record
2
Subfile Record
File
3
Subfile Record
Subfile Record
Type
Text
ARR1
RPG
ARRAYS.....
OERCHGRIC
RPGLE
OERMNT#
RPGLE
OERMNTRI
RPGLE
PARMRPG
RPG
parm checking..............
PARM1
RPGLE
rpgle passsing
POVALID
RPGLE
rpgle passsing
RCVPARM
RPG
check pgmmmmmmmmmmm......
More...
Member
Type
ARR1
RPG
OERCHGRIC RPGLE
OERMNT#
RPGLE
OERMNTRI
RPGLE
F3 = Exit
Types of Subfiles
Load - all Method
Expanding Subfiles
Single Page Subfiles
Load-all Method
To load all of the records that you want to display into the subfile at one
time. After this load is complete, you can display the subfile, which
gives the users access to all of the subfile records by allowing them to
roll backwards and forwards. Subfile handles roll keys.
Data Base Files
File
1
Subfile Format
File
Subfile Record
2
Subfile Record
File
3
Subfile Record
Subfile Record
10
11
File
1
Subfile Format
File
Subfile Record
Subfile Record
File
Subfile Record
Subfile Record
Workstation Display
Subfile Record1
Subfile Record2
Subfile Record
Subfile Record
Workstation Display
Subfile Record3
Subfile Record4
Load fixed number of records into subfile, until user find the information on a
particular page
13
14
Database files
File
1
Subfile Format
Subfile Record
File
1
Subfile Record
One page of
subfile records
loaded into subfile
15
Types Page
Single
of Subfiles
Load Method
3 of 3..Contd.,
Workstation Display
Subfile Record1
Subfile Record2
Clear the existing subfile, and load some more records to subfile
Workstation Display
-----------------
-----------------
Cleared out
16
17
18
REF(DSTREF)
R
SUBFIL
SFL
TEXT('Subfile Record')
CUST
R 7 3
NAME
R 7 10
ADDR
R 7 32
CITY
R 7 54
STATE
R 7 77
A*
19
20
FILCTL
SFLCTL(SUBFIL)
A N70
SFLCLR
A 70
SFLDSPCTL
A 71
SFLDSP
SFLSIZ(15)
SFLPAG(15)
OVERLAY
A 71
A
2'Search Code'
SRHCOD
I
5
10'Name'
32'Address'
14PUTRETAIN
2'Number'
21
HELP allows the user to press the Help key for a displayed message
that describes the valid function keys.
23
Subfile Keywords
SFLPAG (Subfile Page)
SFLSIZ (Subfile Size)
SFLINZ (Subfile Initialization)
SFLLIN (Subfile Line)
SFLRCDNBR (Subfile Record Number)
SFLRNA (Subfile Record Not active)
SFLNXTCHG (Subfile Next Changed)
SFLENTER (Subfile Enter)
SFLCSRRRN (Subfile Cursor Relative Record No.)
+ more..
24
Subfile Keywords
SFLPAG (Records per display) This keyword identifies the
number of records within the subfile that can appear at the
same time. You must specify the SFLPAG keyword for
subfile. SFLPAG cannot be greater than the SFLSIZ
25
Subfile Keywords
SFLSIZ (Subfile Size) - The meaning of this keyword depends
on the value to which the SFLPAG keyword is set. If the
SFLSIZ is equal to the SFLPAG, then the maximum
number of records that can be loaded into the subfile at any
one time is equal to the SFLSIZ. SFLSIZ cannot be less
than the value specified in the SFLPAG keyword. If the
value of SFLSIZ is greater than SFLPAG, then the subfile is
initially sized to handle the number of records specified in
SFLSIZ. However, the subfile will extend itself to handle
more records if the program writes more records than the
number specified in SFLSIZ.
26
Subfile Keywords
SFLINZ (Subfile Initialization) : It allows you to initialize the subfile with
as many active records as the value specified in the SFLSIZ keyword.
If you specify SFLINZ and your subfile size is set to 100, your subfile
would contain 100 active, but blank, subfile records.
SFLRNA (Subfile Record Not Active) : It is used in conjunction with the
SFLINZ keyword. When the two are specified together, the subfile is
initialized with inactive records.
SFLNXTCHG (Subfile Next Changed Record) : It is used to flag a subfile
record as changed and if the program displays it again on the screen,
not lose that attribute. This keyword is specified on the subfile format
because the SFLNXTCHG information will be unique to each subfile
record. It is actually stored in the record, but cannot be viewed on the
screen, similar to a hidden field.
27
Subfile Keywords
SFLEND (Sufile End) : When it is specified, you will get a + pr the
MORE message at the end of your subfile, regardless of whether
the controlling indicator is on or off.
SFLDROP (Subfile Drop) : It tells the subfile program that it should
initially be displayed with only the first subfile line in view. The rest of
the subfile record, which exists on separate lines, should be dropped
from view.
SFLCSRRRN (Subfile Cursor Relative Record Number) : Using this
keyword, the subfile will return the relative record number of the
subfile record on which the cursor was positioned.
SFLLIN (Subfile Line) : Using it you can create a horizontal subfile. In
other words, you can cause a subfile to display more than one subfile
record per line.
28
Subfile Keywords
SFLRCDNBR (Subfile Record Number) : Using it you can control which
subfile page the subfile displays when you output the subfile. By
placing a value in the subfile record number keyword field, the subfile
will locate the page on which that subfile record resides. When it finds
the page, it displays that page first. Then you can roll up and down
from that point.
SFLCLR (Subfile Clear) : It removes all records out of a subfile. If the
user changes the position-to field, the program needs to clear out all the
existing records in the subfile. Then it can set lower limits on the file
and start filling up the subfile up.
SFLENTER (Subfile Enter) : It makes the Enter key act like the roll-up
key. You can then define a function key to act as the Enter key. One
reason you might want to do this is for mouse-controlled terminals
+ more.
29
30
DSPSIZ(24 80 *DS3)
CA03
CA12
A
R SFL1
SFL
A
DBLNAM R
O 5 3REFFLD(PFR/DBLNAM/PMICENTRALF)
A
DBFNAM R
O 5 26REFFLD(PFR/DBFNAM PMICENTRALF)
A
DBNAM R
O 5 49REFFLD(PFR/DBNNAM PMICENTRALF)
A
R SF1CTL
SFLCTL(SFL1)
A
OVERLAY
A N32
SFLDSP
A N31
SFLDSPCTL
A 31
SFLCLR
A 90
SFLEND
A
SFLSIZ(0006)
A
SFLPAG(0006)
31
A
A
A
A
A
A
A
A
A
A
A
A
A
A
1 64DATE
EDTCDE(Y)
2 64TIME
3 11'Last Name'
COLOR(WHT)
3 31'First Name'
COLOR(WHT)
3 52'Nick Name'
COLOR(WHT)
R FKEY1
23 2'F3=Exit'
COLOR(BLU)
23 11'F12=Cancel'
COLOR(BLU)
32
33
A
R SFL1
A
DBLNAM R
A
DBFNAM R
A
DBNAM R
A
R SF1CTL
A
A N32
A N31
A 90
A
A
DSPSIZ(24 80 *DS3)
CA03
CA12
SFL
O 5 3 REFFLD(PFR/DBLNAM/PMICENTRALF)
O 5 26 REFFLD(PFR/DBFNAM PMICENTRALF)
O 5 49 REFFLD(PFR/DBNNAM PMICENTRALF)
SFLCTL(SFL1)
OVERLAY
SFLDSP
SFLDSPCTL
SFLEND
SFLSIZ(0007)
SFLPAG(0006)
34
A
A
A
A
A
A
A
A
A
A
A
A
A
A
1 64DATE
EDTCDE(Y)
2 64TIME
3 11'Last Name'
COLOR(WHT)
3 31'First Name'
COLOR(WHT)
3 52'Nick Name'
COLOR(WHT)
R FKEY1
23 2'F3=Exit'
COLOR(BLU)
23 11'F12=Cancel'
COLOR(BLU)
35
36
DSPSIZ(24 80 *DS3)
CA03
CA12
A
R SFL1
SFL
A
DBLNAM R
O 5 3REFFLD(PFR/DBLNAM/PMICENTRALF)
A
DBFNAM R
O 5 26REFFLD(PFR/DBFNAM PMICENTRALF)
A
DBNAM R
O 5 49REFFLD(PFR/DBNNAM PMICENTRALF)
A
R SF1CTL
SFLCTL(SFL1)
A
OVERLAY
A N32
SFLDSP
A N31
SFLDSPCTL
A 90
SFLEND
A
SFLSIZ(0016)
A
SFLPAG(0004)
37
Display File 2 of 2
0002.10
0002.20
0002.30
0002.40
0002.50
0002.60
0002.70
0002.80
0002.90
0003.00
0003.10
0003.30
0003.40
0003.50
0003.60
A
A
A
A
A
A
A
A
A
A
A
A
A
A
A
RRN1
4S 0H SFLRCDNBR
1 64DATE
EDTCDE(Y)
2 64TIME
3 11'Last Name'
COLOR(WHT)
3 31'First Name'
COLOR(WHT)
3 52'Nick Name'
COLOR(WHT)
R FKEY1
23 2'F3=Exit'
COLOR(BLU)
23 11'F12=Cancel'
COLOR(BLU)
38
Subfile Program 1 of 2
0002.00 FSFL001DF CF E
WORKSTN
0002.02 F
SFILE(SFL1:RRN1)
0004.00 FSFL001LF IF E
k DISK
0005.00 *BUILD THE SUBFILE
0007.00 C
EXSR
sflbld
0008.00 C
DOU
*INKC or *inkl
0009.00 C
WRITE FKEY1
0010.00 C
EXFMT SF1CTL
0011.00 C
ENDDO
0012.00 C
EVAL *INLR = *ON
0012.02 C sflbld begsr
0012.03 *clear subfile
0012.05 C
eval
rrn1=*zero
0012.06 C
eval
*in31 = *on
0012.07 C
write sf1ctl
0012.08 C
eval
*in31 = *off
39
Subfile Program 2 of 2
0013.00 *load the data in subfile
0015.00 C *loval setll sfl001lf
0016.00 C
read
sfl001lf
90
0017.00 C
dow (not *in90) and (rrn1 <= 500)
0017.02 C
eval
rrn1=rrn1+1
0017.03 C
write sfl1
0017.04 C
read
sfl001lf
0017.05 C
enddo
0018.00 *if no records were loaded ,do not display the subfile
0020.00 C
if
rrn1 = *zero
0022.00 C
eval
*in32 = *on
0023.00 C
else
0025.00 C
eval
rrn1=1
0026.00 C
endif
0027.00 C
endsr
40
Message Subfiles
41
MESSAGE SUBFILES
*
42
SUBFILE RECORD
SFLMSGRCD
SFLMSGKEY
SFLPGMQ
SUBFILE CONTROL
SFLDSP
SFLDSPCTL
SFLINZ
SFLPGMQ
SFLSIZ
SFLPAG
SFLEND
43
44
WORKSTN
*--------------------------------------------------------------**
C* Write Message Subfile Control Record.
C
WRITEMSFCTL
C* Write & Read the Data Screen.
C
EXFMTDTASCR
C* Process the Command Keys.
C
EXSR @CMD
C* Clear the Program Queue.
C
MOVE '*CLEAR ' $MSGID
C
MOVE *BLANKS
$MSGDT
C
CALL 'SNDPGM' PARM1
46
$MSGID
PARM1
$MSGID
PARM1
$MSGID
PARM1
*--------------------------------------------------------------**
47
PARM(&MSGID &MSGDTA)
VAR(&MSGID) TYPE(*CHAR) LEN(7)
VAR(&MSGDTA) TYPE(*CHAR) LEN(80)
IF
48