HP 3000 Manuals

Modifying the product_proc Process [ HP ALLBASE/4GL Developer Self-Paced Training Guide ] MPE/iX 5.0 Documentation


HP ALLBASE/4GL Developer Self-Paced Training Guide

Modifying the product_proc Process 

The product_proc process needs to be modified from the point of exit from
the product_scrn screen.  When the user terminates the screen, the
process will check which mode the user has selected, and then update the
file accordingly.  After the file update, the process will display a
message to confirm its success.  If an error occurs during the update,
the process will display an appropriate message.

If you are developing the KSAM based application, continue reading below.

If you are developing the HP ALLBASE/SQL based application, refer to the
"HP ALLBASE/SQL Based Applications" section for a description of the
changes to the process.

If you are developing the HP TurboIMAGE/iX based application, refer to
the "HP TurboIMAGE/iX Based Applications" section for a description of
the changes to the process.

KSAM Based Applications 

The modified product_proc process reads 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-record_not_found
     THEN ENTER 3
8 MESSAGE file_error
9 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                If the data manager returns either 00000 or the
                      value of the constant, this step returns control to
                      step 3 of the process to display the product_scrn 
                      screen again.

                      Values of 00000 or 19111 in *IOSTATUS indicate that
                      all file transactions occurred without error, or
                      that the record could not be found.

                      If the file manager return status is not one 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 8.

Line 8                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 9                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 following 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 these 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.

   1.  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.

   1.  Insert a new step 4

   2.  Enter IF in the Command field.

       This displays the IF command window.

   3.  Complete the fields in this window as explained in the following
       table.

        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.

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.

          Table 7-0.  (cont.) 

        Field                 Entry                         Explanation 
---------------------------------------------------------------------------------------

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.

                                            You will use this field in a later part of
                                            the training guide.

To complete the window and continue: 

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.

       The two steps are very similar to the step you just inserted.
       They 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 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 *WRITE product
8 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: 

Use the following details for each field.

        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 occurred.
                                            The IF command tests to see whether this is
                                            the current value of *IOSTATUS.

AND/OR                |                     This represents OR.

Condition 2           Header Field          The next three fields establish a second
                                            condition that the IF command tests.

Data Name 1           *IOSTATUS

IF test field         =

Data Name 2            N-record_not_found

THEN Statement        ENTER 3               When you complete the condition fields and
                                            press Return, a THEN prompt appears.  Enter
                                            the command shown.

ELSE Statement        Leave blank.

To complete the window and continue: 

The IF command is now complete.

   1.  Press the  Commit Data  function key to commit it.

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 these
       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 .

   2.  Press the  Commit Data  function key now.

Modifying a Step.   

You can now change an existing step.  The ENTER command at step 8 is no
longer required.  This step should now read as:

8 MESSAGE file_error

There are two ways to alter this step.  You could delete step 8 and then
add another step 8 in its place.  However, we shall use the modify
facilities to alter this step.

To modify step 8: 

   *   Position the cursor at the Step Number field and follow the next
       steps. 

Action                    Explanation 

------------------------------------------------------------------------------

Enter 8.                  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 open window and the cursor is
                          positioned in the first position of the window.

Press Shift + Tab, and    This moves the cursor back to the command field.
then Return 

Type MESSAGE over the top This alters the step to a MESSAGE command.
of the ENTER command

Press Return              This displays a new open window for the MESSAGE
                          command.

Enter file_error          This is the message that will be displayed by this
                          command.

Press  Commit Data        Commit the step and HP ALLBASE/4GL will display the
                          modified command.

Adding Commands 

Add the following command to the end of the logic block at step 9.

               9 SCREEN main

This logic command uses an open window for you to enter the logic command
details.

To add the command: 

   1.  Position the cursor on the Action field, regardless of step
       number, and display the whole process on the screen.

   2.  Enter the following information.

Action                    Explanation 

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 using an SQL based application,
continue with the next section.  Otherwise, turn to the Summary section
at the end of the lesson.



MPE/iX 5.0 Documentation