Modifying HP ALLBASE/SQL Based Applications [ HP ALLBASE/4GL Developer Self-Paced Training Guide ] MPE/iX 5.0 Documentation
HP ALLBASE/4GL Developer Self-Paced Training Guide
Modifying HP ALLBASE/SQL Based Applications
The modified product_proc process will read like this:
1 MODE *WRITE product
2 MOVE C-no_record V-product_status
3 SCREEN product_scrn
4 IF V-mode = C-add THEN VISIT add_product
5 IF V-mode = C-modify THEN VISIT modify_product
6 IF V-mode = C-delete THEN VISIT delete_product
7 IF *IOSTATUS <> "00000" & *IOSTATUS <> N-end_of_file
THEN ENTER 10
8 SQL commit
9 ENTER 3
10 MESSAGE file_error
11 SCREEN main
The following paragraphs explain what each step in the process does.
Line 1 This step specifies that the process can write to
the product file.
Line 2 This step initializes the value of the variable V-
product_status when the screen is first displayed.
Line 3 This step displays the product_scrn data screen.
The same screen is used for each mode. The setting
of the mode variable determines how the process
updates the files when the user commits the screen.
Lines 4, 5 and 6 The IF commands test the update mode, and then
invoke the appropriate file update function using
the VISIT command.
Line 7 Values of 00000 or 60110 in *IOSTATUS indicate that
all file transactions occurred without error, or
that the end of the file was reached without
finding the record.
If the file manager return status is neither of
these values, a file error has occurred during the
update functions. In this case, control passes to
the error handling logic starting at step 10.
Line 8 This step calls the SQL logic block commit, which
issues a COMMIT WORK to make any table updates
permanent in the database.
Line 9 This step returns control to step 3 to display the
product_scrn screen again.
Line 10 Control only passes to this step if an error is
detected at step 7. This step displays a message
to warn the user that an error has occurred and the
current product information may be corrupted.
Line 11 This step returns the user to the main menu.
Displaying a menu is one technique you can use to
recover from serious, but non-fatal error
conditions. When HP ALLBASE/4GL displays a menu,
all current activity in the application ceases.
This means that the application returns to a known
condition. To continue from the main menu, the
user must select a menu action. Any actions that
can update data files initiate a process, so all
file record and screen buffers are cleared
automatically.
The next steps show you how to modify the existing process.
Modifying a Process
This part of the lesson shows you how to use facilities that allow you to
modify logic blocks. You use the same methods to modify processes and
functions.
To insert a step:
* Call up the process details screen and follow the next steps.
Action Explanation
------------------------------------------------------------------------------
Enter product_proc This displays the product_proc process in its
current state and places the cursor in the step
number field.
Enter 2 The cursor moves to the action field.
Enter I This indicates that you want to insert a step
before step number 2. The current steps move down
one line, and step 2 becomes blank. Then the
cursor moves to the command field.
Enter MOVE This displays an open window. The MOVE command is
used to copy the contents of a field to another
field.
Enter C-no_record
V-product_status
To complete the window:
The MOVE command is now complete.
* Press the Commit Data function key to commit it.
HP ALLBASE/4GL clears the window and displays the new command at
step 2. The cursor returns to the Step Number field and the step
number is incremented to 3.
Step Number References.
Read the last line of the process. Before you inserted a new step, this
logic step was ENTER 2. Now it is ENTER 3.
HP ALLBASE/4GL has automatically incremented the step number reference as
the SCREEN command has moved down from step 2 to step 3. HP ALLBASE/4GL
updates step number references when you insert or delete lines from a
logic block.
Using the IF Window
The next command that you need to insert is step 4. This contains an IF
command.
To insert a new step 4:
1. Enter IF in the Command field.
This displays the IF command window. The fields on this window
are explained in more detail below.
2. Complete the fields listed below.
Field Entry Explanation
---------------------------------------------------------------------------------------
Condition 1 The first three fields of the IF window
establish the first condition that the IF
command tests. In many cases it is the
only condition.
Data Name 1 V-mode The name of the object to be tested. In
this case, the command tests the variable
mode, which contains one of the four update
modes; add, modify, delete or review.
IF Test = The test to be performed. In this case the
test is whether or not the content of the
mode variable equals the value in the Data
Name 2 field.
Data Name 2 C-add Where an IF Test compares two operands with
a relational operator such as "=", "<",
">", or "<>", you must enter the name of
the second operand in this field.
In this case, the mode variable will be set
to the contents of the add alphanumeric
constant if the user selected Add on the
main menu. The IF command tests to see
whether this is the current value of
V-mode.
Table 7-0. (cont.)
Field Entry Explanation
---------------------------------------------------------------------------------------
AND/OR Leave this field The IF command can test two conditions and
blank. combine the results using a logical AND or
a logical OR connective. The symbols & and
| represent the AND and OR connectives
respectively. When you leave this field
blank, the cursor skips the next three
fields.
THEN Statement VISIT add_product When you leave the AND/OR field blank and
press Return, a THEN prompt appears. The
cursor is placed in the field to the right
of this prompt. This is where you enter
the commands to be performed when the test
is resolved as true. You can execute any
command at this stage except IFLOOP,
SELECT, or another IF statement.
You can specify multiple commands by
separating the commands with a semicolon.
For example, you could enter a string of
commands in this field like this:
MESSAGE added_ok; ENTER 10
ELSE Statement Leave blank. After you enter the THEN statement, the
window displays an ELSE prompt and
positions the cursor in the field beside
the prompt. This is where you enter the
commands to be performed if either test is
resolved as false. This entry follows the
same format as the THEN statement.
However, it is not a required field. If
you don't enter any ELSE commands, control
passes to the next step in the process or
function if the test is resolved as false.
To complete the window:
The IF command is now complete.
1. Press the Commit Data function key to commit it.
HP ALLBASE/4GL clears the window and displays the new command at
step 4. The cursor returns to the Step Number field and the step
number is incremented to 5.
2. Now insert steps 5 and 6, shown below, which are very similar to
the step you just inserted. These two steps also call up
functions to update the product file.
5 IF V-mode = C-modify THEN VISIT modify_product
6 IF V-mode = C-delete THEN VISIT delete_product
At the moment, there are only three update functions available, and the
code is short and simple. However, in later lessons, you will learn how
to introduce more functionality.
Instead of adding a lot of logic commands, you will convert these
decision logic lines into one logic command that calls a decision table.
Decision tables allow you to define a series of actions to be performed
as the result of the outcome of a complex series of conditional tests or
questions.
Your process should now look like this:
1 MODE *WRITE product
2 MOVE C-no_record V-product_status
3 SCREEN product_scrn
4 IF V-mode = C-add THEN VISIT add_product
5 IF V-mode = C-modify THEN VISIT modify_product
6 IF V-mode = C-delete THEN VISIT delete_product
7 FILE *INSERT product
8 SQL commit
9 ENTER 3
Continuing the Change.
The next task is to insert a new step 7. This step also uses the IF
command, but this time, two sets of conditions are tested.
To insert step 7:
Field Entry Explanation
---------------------------------------------------------------------------------------
Command IF
Data Name 1 *IOSTATUS In this case, the command tests the HP
ALLBASE/4GL communication field *IOSTATUS,
which contains either zero, or the error
message number returned by the HP
ALLBASE/4GL data manager after an access to
an application data file.
IF Test <>
Data Name 2 "00000" The value "00000" will be the content of
*IOSTATUS if no file errors have occured.
The IF command tests to see whether this is
the current value of *IOSTATUS.
Table 7-0. (cont.)
Field Entry Explanation
---------------------------------------------------------------------------------------
AND/OR & This represents AND.
Condition 2 The next three fields establish a second
condition that the IF command tests.
Data Name 1 *IOSTATUS
IF test <>
Data Name 2 N-end_of_file
THEN Statement ENTER 10 When you complete the condition fields and
press Return, a THEN prompt appears. Enter
the command shown.
To complete the window:
The IF command is now complete.
1. Press the Commit Data function key to commit it.
Adding Commands.
The following commands can be added to the end of the logic block at
steps 11 and 12 respectively. Both of these logic commands use open
windows for you to enter the logic command details.
1. Add the commands as shown below.
11 MESSAGE file_error
12 SCREEN main
Deleting a Step.
You can now delete an existing step. We wish to delete the FILE step.
1. Make sure the cursor is at the Step Number field, and follow the
next steps.
Action Explanation
Enter 8 The cursor moves to the action field.
Enter D This indicates that you wish to delete the current
step.
Press Return Step 8 is deleted from the logic block, and the
steps below it are moved up.
A message is then displayed at the bottom of the screen, prompting you to
press the Commit Data key to make the deletion permanent. The D action
blanks out the step from the screen. However, the step is not actually
deleted from the logic block until you press Commit Data .
1. Press the Commit Data function key now.
Modifying a Step.
You can now change an existing step. When you entered step 7, you
entered the ENTER command as it should finally appear, but this did not
point to the correct step at the time. The adjustments HP ALLBASE/4GL
made to this step number when you deleted step 8 mean that the ENTER
command now refers to the wrong step.
You now need to change this command so that, once again, it refers to the
correct step.
1. Position the cursor at the Step Number field and follow these
steps.
Action Explanation
------------------------------------------------------------------------------
Enter 7. The cursor moves to the action field.
Press Return Since the default action for an existing step is
Change, the current contents of the step are
displayed in an IF window and the cursor is
positioned in the first field of the window.
Press Tab seven times This moves the cursor through the fields to the
THEN field on the screen.
Type 10 over the top of This alters the step so that if both test
the number 9 conditions in the IF command are true, processing
control skips to step 10.
Press Commit Data Commit the step and HP ALLBASE/4GL will display the
modified command.
2. Position the cursor on the Action field, regardless of step
number, and display the whole process on the screen.
Action Notes
------------------------------------------------------------------------------
Enter L The L action lists the current logic block to the
screen. When you press Return, HP ALLBASE/4GL
clears the screen and lists the entire process.
Any lines that are too long to fit on the screen
will be wrapped around to the next line.
Press Return This returns you to the process details screen.
3. Press the Generate Process function key to generate the modified
product_proc process.
If you have entered the process exactly as it's listed at the
beginning of this section, you won't receive any generate error
messages. If you receive any generate errors, check that the
storage items you defined previously are correctly named. This is
the most likely source of error.
This concludes this lesson. If you are not modifying an HP TurboIMAGE/iX
application, turn to the Summary section.
MPE/iX 5.0 Documentation