Objectives [ HP ALLBASE/4GL Developer Self-Paced Training Guide ] MPE/iX 5.0 Documentation
HP ALLBASE/4GL Developer Self-Paced Training Guide
Objectives
When you have completed this lesson, you will have learned how to:
* Alter processes
* Create new logic blocks
Modifying the product_proc Process
Although this process is slightly different for each data manager, its
function is the same for all data managers.
To modify the logic block:
1. Modify the product_proc process as shown below for your data
manager and regenerate the process.
2. Then turn to the description of the product on the following
pages.
a. KSAM Based Applications
1 MODE *WRITE product option
2 MOVE C-product V-current_record
3 MOVE C-no_record V-product_status
4 TRANSACT *BEGIN
5 SCREEN product_scrn
6 DECISION prod_opt_update
7 IF *IOSTATUS <> "00000" & *IOSTATUS <>
N-record_not_found
THEN ENTER 10
8 TRANSACT *END
9 ENTER 4
10 MESSAGE no_transact
11 TRANSACT *UNDO
12 SCREEN main
b. HP ALLBASE/SQL Based Applications
1 MODE *WRITE product option
2 MOVE C-product V-current_record
3 MOVE C-no_record V-product_status
4 TRANSACT *BEGIN
5 SCREEN product_scrn
6 DECISION prod_opt_update
7 IF *IOSTATUS <> "00000" & *IOSTATUS <> N-end_of_file
THEN ENTER 11
8 SQL commit
9 TRANSACT *END
10 ENTER 4
11 MESSAGE no_transact
12 TRANSACT *UNDO
13 SCREEN main
c. HP TurboIMAGE/iX Based Applications
1 DM IMAGE *MODE *MODLOCK :D-traindb
2 MODE *UNLOCK product option
3 MOVE C-product V-current_record
4 MOVE C-no_record V-product_status
5 TRANSACT *BEGIN
6 SCREEN product_scrn
7 DECISION prod_opt_update
8 IF *IOSTATUS <> "00000" & *IOSTATUS <>
N-record_not_found
THEN ENTER 12
9 TRANSACT *END
10 DM IMAGE *UNLOCK :D-traindb
11 ENTER 5
12 MESSAGE no_transact
13 SCREEN main
Understanding the Modifications to the Logic
The new and altered steps in this process are described below.
* The altered MODE command.
This step now sets the mode for both the product and option files.
For the HP TurboIMAGE/iX based application, the *UNLOCK mode is
now used. This is necessary because the FILE *BUFFER commands in
the functions you will create later release all locks held on the
traindb database in *WRITE mode. This would cause HP ALLBASE/4GL
to attempt file operations with no lock placed on a data set,
which the DM IMAGE *MODLOCK command does not allow. Using MODE
*UNLOCK, locks are only released when a FILE *UNLOCK command or a
DM IMAGE *UNLOCK is executed.
* The new MOVE command.
This step ensures that the current record type is a product record
when the screen is first displayed. Options can only be accessed
after an existing product has been retrieved from the product
file.
* The TRANSACT commands.
This logic block introduces the TRANSACT command. The TRANSACT
command defines groups of file operations that make up one logical
transaction.
In this application, adding new products and deleting existing
products are transactions that involve changes to two data files.
To ensure logical consistency of the data files, both files must
be updated successfully during the transaction. If a system
failure occurs in the time between the two files being updated,
the data files could be left in a mutually inconsistent state. In
this type of situation, you can use the TRANSACT command to mark
the beginning and end of the logical transaction. The TRANSACT
*BEGIN command marks the beginning of the transaction, and the
TRANSACT *END command marks the end.
The TRANSACT *UNDO command reverses all file transactions that
have occurred since the last TRANSACT *BEGIN command. For
transactions that involve HP TurboIMAGE/iX data sets, the TRANSACT
* UNDO command does NOT reverse the transactions, so the command is
not included in the version of this process used by HP
TurboIMAGE/iX application developers.
* The DECISION command.
The DECISION command executes a decision table. The decision
table tests the update mode and record type, and then invokes the
appropriate file update function. This replaces the previous
version of the product_proc process, where separate logic lines
were used to make a decision. For situations where there are
quite a number of outcomes, a decision table is faster and tidier
than using a large number of logic lines.
* The altered IF command.
This command is only changed for the KSAM based application. This
command still checks to see whether an error occurred. If no
error occurs or the record is not found, HP ALLBASE/4GL moves to
the next step. The new step at step 9 passes control back to step
4 of the process. If an error, other than a record not found
error, occurs, control passes to step 10 to the error handling
steps.
* The altered MESSAGE command.
Control only passes to this step if an error is detected at step 7
(step 8 for HP TurboIMAGE/iX based applications). This step
displays a message to warn the user that an error has occurred and
the current product information may be corrupted. The file_error
message has been replaced by a more specific warning message.
To create the accompanying message:
1. For KSAM based and HP ALLBASE/SQL based applications, create the
following message.
2. For HP TurboIMAGE/iX based applications, create the same message,
without the last line of the message. The last line is not
necessary because HP TurboIMAGE/iX file transactions cannot be
reversed within HP ALLBASE/4GL.
a. Message - no_transact
Name no_transact
Type WARN
Contents "A file error has occurred. "
"This transaction will be reversed."
MPE/iX 5.0 Documentation