RPG IV - Chapter 12

Download Report

Transcript RPG IV - Chapter 12

RPG IV
Interactive Programs: Advanced
Techniques - Chapter 12
Objectives
Use Subfiles
Use on-line help
Subfiles
A collection of records that is handled
as a unit for screen I/O
Subfiles consist of the Subfile Record
Format and the Subfile ControlRecord Format
Subfile Record Format
The subfile record format describes
the fields that are to appear on the
screen
A new record-level keyword is
required, SFL(subfile), which
identifies this format as a subfile
Subfile Control-Record Formats
The subfile control-record format
must immediately follow the subfile
record format
This record format controls the
display of the subfile records through
the use of special record-level
keywords
Column headings are also included in
this record format
Subfile Control-Record Keywords
SFLCTL
SFLDSP
SFLSIZ
SFLDSPCTL
SFLCLR
Loading the Entire Subfile
Define the subfile size large enough to
hold the maximum expected number
of records
Easiest to code but results in the
slowest initial response time
Once the display begins, however,
paging through the subfile is fast
Loading the Entire
Subfile(cont.)
This method is least appropriate when
there are large number of records to be
loaded and the user is likely to want to
see most of them
SFLSIZ must be large enough to hold
all the data
File Spec Modifications
Code SFILE in the Keywords area
Code the subfile record format name,
a colon, and the field to be used to
store the relative record number as
parameters
Logic for loading Entire Subfile
Chain to the file and write them to the
subfile
Load the subfile until there are no more
records
Then the subfile can be displayed by
executing the subfile control-record format
Because SFLPAGE is less that SFLSIZ, the
system will handle any user request to roll
up or roll down
Upon return the program should either end
or request another course
Loading Subfile Page at a Time
Variation #1- Subfile one greater than
page
Subfile Size One greater than Page
The system will automatically expand a
subfile, regardless of its stated size, as
your program adds more records to it
When the user attempts to roll up past
the last page in the subfile, however,
control returns to the program, which
must load an additional page
Loading Subfile Page at a Time
Variation #1 - Continued
ROLLUP keyword must be associated
with an indicator to allow the system to
send control back to the program
You must also add the SFLEND keyword
If the SFLEND indicator is off, the system
displays a + sign and returns control to
your program to load the next page
If the SFLEND indicator is on, the + sign is
not displayed, and control is not returned
to your program for additional loading
Loading Subfile Page at a Time
Variation #1 - Continued
Thus your program should turn on the
SFLEND indicator when no additional
records remain
The third keyword needed is SFLRCDNBR
coded within the subfile control-record
format opposite a hidden field
The value of the hidden field determines
which page of the subfile is displayed
Logic for Variation #1
Each time control returns to the
program from the screen, if the
return was triggered by the roll key,
the program must load the next page
of the subfile and return back to the
screen
When there are no more records left
to load, the program should turn on
the SFLEND indicator to disable
rolling past the last subfile page
Logic for Variation #1 cont.
To determine whether additional
pages can be built, the program
needs to read one additional record
after loading an entire subfile page
before displaying the new page
The load subroutine only writes out
15 records to the subfile, that is one
page
Loading Subfile Page at a Time
Variation #2- Subfile much bigger
than page
This method of building subfile a page
at a time, setting size much bigger that
page, is really just a variant of loading
the entire subfile at once
However, like variation #1, this method
builds the subfile just a page at a time,
instead of putting all the appropriate
records in the subfile prior to any display
Loading Subfile Page at a Time
Variation #2- Continued
This method is appropriate when a large
number of records need to be stored in a
subfile, because the large specified size
allocates adjacent disk space for faster
access
You should probably not use this
method if the expected subfile exceeds
100 records
Loading Subfile Page at a Time
Variation #2 - Continued
In the display file, you merely need to
change the subfile size ad move ROLLUP
keyword from the subfile control-record
format to the subfile record format
The program logic is the same as
Variation #1
Loading Subfile Page at a Time
Variation #3- Subfile size equals page
Setting subfile size equal to page is most
appropriate when the user is likely to want
to roll through a large number of records
Rolling forward requires replacing the
existing page with the next page through
loading; because rolling backward
requires replacing the existing page with
records already read, program logic
required by this technique is more
complicated
Loading Subfile Page at a Time
Variation #3- Subfile size equals page
With this method, the subfile stores only
one page of records
As an alternative to enabling
ROLLDOWN, programmers require users
to restart the subfile at the beginning
In the DDS the subfile size equals page
and keyword SFLRCDNBR is not used
Logic for Variation #3
First, before each loading of the subfile,
the subfile must be cleared, since the
new records should completely replace
the previously displayed records
Second, the program must check the
roll-key indicator and indicator 04 upon
return from the screen to determine
whether to build the next page of the
subfile or to restart at the beginning of
the subfile
Subfiles and Change
READC (Read next Changed record)
Used only with subfiles
Used in a loop, reads only those records
from a subfile that have been modified
during a prior EXFMT operation
Subfile fields need to have different
names than the database
Change usage on fields to B in the
display
On-Line Help
Help is evoked by pressing the HELP
key
The help text may reside in an Office
Vision/400 document, in records within
a separate display file, or as records
with the display file used in the
interactive application
First, you need to include the keyword
HELP, at either the file or records level,
to enable the Help key
Global Help
With the Help key enabled, pressing it
will display help information
associated either with the entire
display or with a specific area of the
display
For the entire display, you need in
addition to the keyword HELP, a filelevel keyword HLPRCD, coupled with
the name of the record format
containing the help text
Cursive-Sensitive Help
The HLPARA (Help area) associated
with the help specification defines a
rectangular area on the screen; if the
cursor is within this area and the user
presses the Help key, the help text is
displayed
In addition to the HLPARA, the help
specification includes keyword
HLPRCD to designate which record
should be displayed
Points to Remember
To define subfiles within DDS requires
two kinds of record formats
One that defines the fields within the
subfile and describes the field
locations within a screen line
And a second format, called a subfile
control-record format, that actually
manages the displaying of the subfile
information
Points to Remember cont.
Several required keywords are used
with subfiles
Record-level keyword SFL identifies a
record format as a subfile record,
while record-level keyword SFLCTL
identifies a format as a subfile
control-record format
Points to Remember cont.
Several different techniques exist for
loading and displaying subfiles
The AS/400 allows you to associate
on-line help with an entire screen or
with specific areas of the screen that
the user can access through the Help
key