HP 3000 Manuals

Automatic Error Handling [ HP Transact Reference Manual ] MPE/iX 5.0 Documentation


HP Transact Reference Manual

Automatic Error Handling 

Transact automatically traps various types of errors encountered during
the execution of a program and takes certain predetermined actions.
Transact traps errors during data entry, during database or file
operations, and during arithmetic calculations in LET expressions.

Data Entry Errors 

Transact validates a value entered as a response to a data entry prompt.
This is done according to attributes defined for the data item in a data
dictionary or the Transact program--that is, data type, field size,
decimal field length, integer field length.  If it detects an error
during validation, it issues an appropriate error message on the terminal
and reissues the data entry prompt.

Database or File Operation Errors 

Transact assumes that a data set or file error was caused by an incorrect
user input--for example, by the user specifying an incorrect value for a
key item.  (Other types of software error conditions should be eliminated
before the program is put into production mode.)  If Transact detects an
error, it generates an error message and returns program control to an
appropriate statement preceding the data set or file operation.

The return location can be the start of the command sequence.  In this
case, the program reissues the command prompt to allow the user to start
over with a command.  The return location can be to a data entry prompt
too.  For instance, if an error occurs on the second of two database or
file operation verbs and there is a data entry prompt between the two,
the return location is the prompt statement immediately following the
first database or file operation.

The intention of the logic that determines the return location is to
restart at a program point that allows a corrected value to be entered,
one that will not cause the error to recur.  If you choose to use
automatic error handling, do not include statements between the prompts
and file or database access verbs which may alter the data used in the
operation.  This is important because automatic error handling
re-executes all statements between where the error occurred (such as the
file or database operation) and where the data was collected (such as the
PROMPT verb).  Ignoring this caution may give you unanticipated results.
For example:

     (1)  LET (COUNTER) = 0;

     (2)  PROMPT (DATA-ITEM);

     (3)  LET (COUNTER) = (COUNTER) + 1;

     (4)  FIND (DATA-ITEM);

     (5)  PUT DATASET, LIST=(DATA-ITEM,COUNTER);

Consider the following:

   1.  The user enters the data item in response to PROMPT in (2).

   2.  The program increments the counter from 0 to 1 in (3).

   3.  The data item entered in (2) causes an error in the FIND operation
       in (4).

   4.  Automatic error handling causes the program to repeat (2).

   5.  The user receives an error message from the database and is
       prompted again for DATA-ITEM.

   6.  The user enters the corrected DATA-ITEM.

   7.  The program increments the counter from 1 to 2 in (3).

   8.  The FIND operation in (4) is now successful.

   9.  The PUT operation in (5) stores the count of 2--which may not be
       the desired result.

If you want to return to a location of your choice where you can process
the error, you can use the "ERROR=label" option on the associated file or
data set operation statement.

There are some conditions under which the ERROR= option is not taken when
no entry is found.  This information is summarized in Table 7-1 .

Table 7-4  shows the contents of the status register following a
database or file access statement when the STATUS option is not used.

You can test the contents of the STATUS register with an IF statement
within your own error routines at a label specified by the ERROR= option.
You can display the contents of the register by first assigning it to a
32-bit data item.  The data item should be type I(10,,4) to hold the
maximum STATUS value.  For example:

     DEFINE(ITEM) STAT I(10,,4);
     LIST STAT;
     LET (STAT) = STATUS;
     DISPLAY STAT;

In addition to branching, the ERROR= option sets a value to the status
register to identify the type of error.

          Table 7-1.  Circumstances that Determine Whether ERROR= Branch Is Taken during Database and File Operations 

-------------------------------------------------------------------------------------
|           |                 |        |        |        |        |                 |
|           |      Chain      | Serial |        |        |        |                 |
| Modifier  |     RChain      | RSerial| Direct | Current| Primary|      None       |
|           |                 |        |        |        |        |                 |
-------------------------------------------------------------------------------------
|           |        |        |        |        |        |        |        |        |
| Database  | No     | No     | No     | Invalid| No     | No     | No     | No     |
| or File   | entry  | master | record | record | cur-   | master | entry  | master |
| Error     |        |        |        | number | rent   |        |        |        |
|           |        |        |        |        | record |        |        |        |
|           |        |        |        |        | de-    |        |        |        |
|           |        |        |        |        | fined  |        |        |        |
|           |        |        |        |        |        |        |        |        |
-------------------------------------------------------------------------------------
|           |        |        |        |        |        |        |        |        |
| Delete    | N      | Y      | N      | Y      | Y      | Y      | N/A    | Y      |
|           |        |        |        |        |        |        |        |        |

| Delete    | Y      | Y      | Y      | Y      | Y      | Y      | N/A    | Y      |
| (S)       |        |        |        |        |        |        |        |        |
|           |        |        |        |        |        |        |        |        |
-------------------------------------------------------------------------------------
|           |        |        |        |        |        |        |        |        |
| Find      | N      | N      | N      | Y      | N      | N      | N/A    | N      |
|           |        |        |        |        |        |        |        |        |
| Find (S)  | Y      | Y      | Y      | Y      | N      | N      | N/A    | N      |
|           |        |        |        |        |        |        |        |        |
-------------------------------------------------------------------------------------
|           |        |        |        |        |        |        |        |        |
| Get       | Y      | Y      | Y      | Y      | Y      | Y      | N/A    | Y      |
|           |        |        |        |        |        |        |        |        |
| Get (S)   | Y      | Y      | Y      | Y      | Y      | Y      | N/A    | Y      |
|           |        |        |        |        |        |        |        |        |
-------------------------------------------------------------------------------------
|           |        |        |        |        |        |        |        |        |
| Output    | N      | Y      | N      | Y      | Y      | Y      | N/A    | Y      |
|           |        |        |        |        |        |        |        |        |
| Output    | Y      | Y      | Y      | Y      | Y      | Y      | N/A    | Y      |
| (S)       |        |        |        |        |        |        |        |        |
|           |        |        |        |        |        |        |        |        |
-------------------------------------------------------------------------------------
|           |        |        |        |        |        |        |        |        |
| Path      | N/A    | N/A    | N/A    | N/A    | N/A    | N/A    | N      | N      |
|           |        |        |        |        |        |        |        |        |
| Path (S)  | N/A    | N/A    | N/A    | N/A    | N/A    | N/A    | N      | Y      |
|           |        |        |        |        |        |        |        |        |
-------------------------------------------------------------------------------------
|           |        |        |        |        |        |        |        |        |
| Put       | N/A    | N/A    | N/A    | N/A    | N/A    | N/A    | N/A    | Y      |
|           |        |        |        |        |        |        |        |        |
| Put (S)   | N/A    | N/A    | N/A    | N/A    | N/A    | N/A    | N/A    | Y      |
|           |        |        |        |        |        |        |        |        |
-------------------------------------------------------------------------------------
|           |        |        |        |        |        |        |        |        |
| Replace   | N      | Y      | N      | Y      | Y      | Y      | N/A    | Y      |
|           |        |        |        |        |        |        |        |        |
| Replace   | Y      | Y      | Y      | Y      | Y      | Y      | N/A    | Y      |
| (S)       |        |        |        |        |        |        |        |        |
|           |        |        |        |        |        |        |        |        |
-------------------------------------------------------------------------------------

       Y   = Taken
       N   = Not taken
      (S)  = Status option used

Arithmetic Calculations 

Arithmetic errors can be handled within a Transact program by including
the ERROR= option on the LET verb.  (See a complete discussion under LET
in Chapter 8.)



MPE/iX 5.0 Documentation