Module Operation [ HP ALLBASE/4GL Developer Reference Manual Vol. 1 ] MPE/iX 5.0 Documentation
HP ALLBASE/4GL Developer Reference Manual Vol. 1
Module Operation
Module operation complies with an application structure defined in the
templates. This application structure may not match the appearance or
structure of your application. However, you can modify the templates if
you want to change the way the module operates. This is covered in the
subsection Module Construction and Templates.
Module Capabilities
The resultant screen and logic that HP ALLBASE/4GL creates for the module
allows the user to retrieve records from the file. Scanning the file
allows the user to retrieve records on a first, last, next, or previous
record basis.
With HP ALLBASE/SQL tables, HP TurboIMAGE/iX data sets, and KSAM data
files, keyed access is also provided. Keyed access allows the user to
retrieve records based on full-key or partial-key reads. A full-key read
retrieves a record with a value in its key field that matches the value
the user entered. A partial-key read retrieves a record with a value in
its key field that is equal or greater than the value the user entered.
NOTE Within this section, the term keyed files will refer to the three
file types that offer keyed access: HP ALLBASE/SQL tables, HP
TurboIMAGE/iX data sets, and KSAM data files. Keyed files must
contain a key. Any HP ALLBASE/SQL tables, HP TurboIMAGE/iX data
sets, or KSAM data files that do not contain a key field cannot be
used to build a module.
Record retrieval capabilities are available in both inquiry (I type)
modules and maintenance (M type) modules. In maintenance modules, the
screen and logic created by the module builder also allow the user to add
records, delete records, and modify existing records.
The following module capabilities table summarizes the capabilities of a
module, including how they are influenced by module type and file type.
Table 8-1. Module Capabilities
---------------------------------------------------------------------------------------------------
- - File Type -
---------------------------------------------------------------------------------------------------
- - Keyed File - Serial -
---------------------------------------------------------------------------------------------------
| Capabilities | Unique | Duplicate | Fixed | Variable |
| | Key | Key | Length | Length |
---------------------------------------------------------------------------------------------------
- File Scanning - Yes - Yes - Yes - Yes -
---------------------------------------------------------------------------------------------------
- Full-Key Read - Yes - Yes - No - No -
---------------------------------------------------------------------------------------------------
- Partial-Key Read - Yes - Yes - No - No -
---------------------------------------------------------------------------------------------------
- Add Records - Yes - Yes - Yes - Yes -
---------------------------------------------------------------------------------------------------
- Insert Records - No - Yes - No - No -
---------------------------------------------------------------------------------------------------
- Modify Records - Yes - Yes - Yes - No -
---------------------------------------------------------------------------------------------------
- Delete Records - Yes - Yes - No - No -
---------------------------------------------------------------------------------------------------
It is important to realize that many aspects of the module builder,
including the capabilities of the module, are influenced by both the type
of HP ALLBASE/4GL file accessed and the module type.
Another capability you can include in a module is link fields in the data
screen. With link fields the user can access data from up to twenty
other keyed files in addition to the main file for the module. The
module can only read information from these secondary files. In
maintenance and inquiry modules, this information can be displayed on the
data screen. In maintenance modules, this information can also be used
for data validation.
Process
Users access the module through a menu item. The menu item executes the
main process, which initializes the access mode and displays the
resultant screen. This transfers control of the application to the
resultant screen. Control returns to the main process when the user
presses the Commit Data function key. The process then performs the
appropriate file transaction and returns control to the data screen. The
process terminates when the user presses the Previous Menu function
key.
Data Screen
In an inquiry module, all fields on the resultant screen, except the
first field, are display-only. In a maintenance module, all fields from
the main file are input fields on the resultant screen. Fields
displaying data from secondary files are always display-only fields.
The first line of the resultant screen is the banner line. It consists
of the application name at the left, a screen title in the center, and
the screen name at the right. The rest of the screen is used for label
and field pairs. The label provides an on-screen name for the field.
The first pair is the input key field and its label, and is normally
separated from the remaining screen fields. When the main file is a
keyed file, the user uses this field for keyed access to the main file.
In resultant screens that access serial files, this label and field pair
is still separate from the remaining fields.
The format of the screen depends on the length, type, and number of
fields placed on the screen. When creating the resultant screen, the
module builder first attempts to place all the label and field pairs in
one column down the center of the screen. If there are too many fields
for this layout, the module builder then tries to place all the label and
field pairs in two columns. Finally, if there are too many label and
field pairs for a two column layout, the module builder tries to fit as
many label and field pairs as possible onto the resultant screen.
The tabbing sequence through the screen fields is from top left to bottom
right. The cursor moves across the fields in each line from left to
right, and then down to the left-hand field of the next line.
Refer to Module Construction and Templates for further information on how
the module builder creates the resultant screen.
File Scanning
File scanning is the only access method that is common to all HP
ALLBASE/4GL file types. The user can use file scanning in both inquiry
and maintenance modules. File scanning allows the user to select the
first, next, previous, or last record from the file. All scanning is
controlled with the function key sets. Four function keys are available
to the user for scanning: Previous Record , Next Record , First
Record , and Last Record .
The function keys for scanning can be placed in one or more function key
sets, depending on the file type and module type. Inquiry modules
contain all the available scanning function keys in a single function key
set, which is always displayed. Maintenance modules generally require
two to six sets of function keys to display the available scanning keys.
However, from the user's perspective, only two sets of function keys are
used to display the function keys for file scanning. The first set
displays the Previous Record and Next Record function keys. The
second set displays the First Record and Last Record function keys.
The More Keys function key in the first set, and the Main Keys
function key in the second set, are used to switch between the two sets
of function keys.
The following table shows the scanning operations that are available for
the various file types.
Table 8-2. Scanning Capabilities by File Type
------------------------------------------------------------------------------------------------------
- - File Type -
------------------------------------------------------------------------------------------------------
| | HP ALLBASE/SQL | KSAM & HP | SERIAL |
| | | TurboIMAGE/iX | |
------------------------------------------------------------------------------------------------------
| Scan Type | Unique | Duplicate | Unique & | Fixed | Variable |
| | Key | Key | Duplicate | Length | Length |
------------------------------------------------------------------------------------------------------
- First Record - Yes - Yes - Yes - Yes - Yes -
------------------------------------------------------------------------------------------------------
- Next Record - Yes - Yes - Yes - Yes - Yes -
------------------------------------------------------------------------------------------------------
- Previous Record - Yes - No - Yes - Yes - No -
------------------------------------------------------------------------------------------------------
| Previous Key | No | Yes | No | No | No |
| Value | | | | | |
------------------------------------------------------------------------------------------------------
- Last Record - Yes - No - Yes - Yes - No -
------------------------------------------------------------------------------------------------------
- Last Key Value - No - Yes - No - No - No -
------------------------------------------------------------------------------------------------------
The user can always step forward through a file, either from the current
record or from the first record in the file. For keyed files, the order
in which successive records are retrieved is ascending key field
sequence. Records in serial files are retrieved in the physical order in
which they are stored in the file, which is normally the order they are
created. There is no ascending or descending key value sequence.
Keyed Access
Keyed access is available for keyed files, that is, HP ALLBASE/SQL
tables, HP TurboIMAGE/iX data sets, and KSAM data files. Both inquiry
and maintenance modules allow keyed access.
Where the record layout allows unique key values, the user can use keyed
access to retrieve a specific record. This is done by entering a value
in the key field and pressing Return. HP ALLBASE/4GL attempts to locate
and display a record with a matching key value. This is a full key read
of the main file, and is available whenever the cursor is in the key
field.
If a record is located, the user can access records with key values
adjacent to that entered by pressing the Previous Record and Next
Record function keys. In a maintenance module, the user can modify the
retrieved record or add a new record if no record is found.
Where the record layout allows duplicate key values, keyed access
retrieves only the first record with a matching value. The user then
presses the Next Record function key to step through successive records
with the same key value. For HP ALLBASE/SQL tables with duplicate keys
allowed, the Previous Record function key is replaced with the Prev
Key Value function key. When the user presses this function key, HP
ALLBASE/4GL searches back through the table for the key value preceding
the value displayed. It then retrieves the first record in the table
with this key value.
If after entering a value, the user presses the Next Record function
key instead of Return, the partial key read function is invoked. This
function attempts to retrieve the first record that matches or is greater
than the contents of the key field. In all field types, except numerical
and date, records are ordered by ASCII coding for retrieval.
Maintenance Modules
A maintenance module allows the user to add new records, and delete or
modify existing records in the file. Each action is performed when the
module is in the corresponding mode for the action. The current module
mode is displayed in the label for the Mode function key, located in
the bottom left corner of the screen. To change the module mode, the
user presses the Mode function key until the required mode is attained.
The mode indicates the type of change that will be made to the file when
the user presses the Commit Data function key.
HP ALLBASE/4GL automatically sets the mode based upon the previous action
by the user. If required, the user can then change the mode as required
to another available mode by pressing the Mode function key.
Files with Unique Keys.
When working with keyed files with unique keys, the module has three
possible modes: add, modify, and delete. When the user first enters the
resultant screen, the mode is set to add.
In add mode, if the user enters a value into the key field and
successfully retrieves a record, HP ALLBASE/4GL changes the mode to
modify.
In modify mode, if the user enters a key value that doesn't retrieve a
record, HP ALLBASE/4GL changes the mode to add, holding the entered value
in the key field.
From modify mode, the user can toggle to delete mode if required.
Delete mode remains the current mode until the user changes it. When the
user presses the Mode function key, HP ALLBASE/4GL changes the mode to
modify if an existing record is displayed, otherwise it changes the mode
to add.
Files with Duplicate Keys.
When working with keyed files where duplicate keys are allowed, the
module has three possible modes: add, modify, and delete. When the user
first enters the resultant screen, the mode is set to add.
Add mode remains the current mode until the user changes it to modify or
delete mode. While in add mode, if the user presses the Commit Data
function key with an existing key displayed, another record with the same
key value is inserted into the file.
From modify mode, if the user enters a key value that exists, HP
ALLBASE/4GL retrieves the first record with that key and holds modify
mode. If no record is retrieved, HP ALLBASE/4GL changes to add mode.
While in modify mode, the user can change to add or delete mode.
Delete mode remains the current mode until the user changes it. When the
user presses the Mode function key, HP ALLBASE/4GL changes the mode to
modify if an existing record is displayed, otherwise it changes the mode
to add.
Serial Files.
When working with fixed-length serial files, the user has two available
modes: add and modify. The mode is set to add when the user first
enters the resultant screen.
From add mode, if the user uses any of the four function keys for
scanning, HP ALLBASE/4GL changes the mode to modify. The module remains
in modify mode until the user changes it to add.
With variable length serial files, the user has two available modes: add
and review. Add is only available when the user is at the end of the
file.
In add mode, if the user presses the Mode , First Record, or Next
Record function key, HP ALLBASE/4GL moves to the beginning of the file
and changes to review mode.
In review mode, if the user presses the Mode function key, HP
ALLBASE/4GL moves to the end of the file and changes the mode to add.
Secondary Files
With module builder you can specify that a field in the resultant screen
is linked to one of the following:
* A key field in an indexed KSAM file record.
* A key field in an HP TurboIMAGE/iX file record.
* Any field in an HP ALLBASE/SQL table record.
When creating the module, HP ALLBASE/4GL links this field to a secondary
file. The secondary file can then be used to display additional
information and to validate user data entry.
Secondary File Functions.
For each field in the resultant screen that is linked to a secondary
file, the module builder creates an after function to retrieve the
appropriate record from the secondary file. In maintenance modules, the
after function can also be used to validate the data entered. If the
link field is an input field, the function is executed as an after
function. In addition, regardless of the field type, the function is
always executed as a result of the SHOW command.
Additional Information Display.
After the user enters data into the link field, the after function uses
that value as the key to retrieve a record from the specified secondary
file. If a record cannot be retrieved, a warning message is displayed.
If a record is retrieved, this data is available in the file record
buffer and can be displayed on the resultant screen. Any fields
displaying data from the retrieved record must appear on the screen after
the link field. That is, the display fields must have a higher sequence
number.
Data Validation.
When you specify the link between a screen field and a secondary file,
you can also specify whether that field is validated against the
secondary file. When validation is specified, the secondary file record
must be retrieved before the user can commit data in the link field and
continue entering data into further fields. If the validation fails, an
error message is displayed and the field cannot be committed until the
data is validated, or the field is blank.
Limitations.
All keyed file types can be used as secondary files. Serial files cannot
be used as secondary files.
If the index field for the secondary file allows duplicate values, the
first record found will be retrieved.
A file cannot be used more than once in a module. Therefore, the main
file cannot be used as a secondary file within the same module, and a
secondary file can only be linked to one screen field. The only limit to
the number of fields that can be displayed from a secondary file is the
number of fields that can fit on the screen.
A maximum of twenty secondary files per module is allowed.
MPE/iX 5.0 Documentation