Exercise 7.9: Adding field error handling

Before you begin, you must complete Exercise 7.8: Switching between multiple records.

Let's put in some error handling for the 'position to employee name' field. If the employee name is not found in the database, the program will set on indicator 60.

In this case the field should turn red, reverse image and position the cursor to it. Now wouldn't it be better if you had something easier to remember than some arbitrary number from 1 to 99.

To set indicators:

  1. Click the Change named indicator sets Change named indicator sets button button on the Design page toolbar (or press F7.)

    The Named indicator sets window opens.

  2. In the Settings name field, type: Not Found.
  3. Click Create.
    Named indicator sets window
  4. Select the check box next to 60 and click OK.

    The Not found indicator set is now in effect. The Design area is shown as if indicator 60 was on and all other indicators were off. The Design page toolbar shows the current indicator set in the Select named indicator set list on the bottom left.
    Select named indicator set list

  5. Now select the POS_TO field.
  6. On the toolbar, select the color red and the display attributes reverse image and position cursor. (The set of toolbar buttons representing the current display attributes is found just below the color button).

    The toolbar should look as follows:
    Toolbar

  7. Examine the DDS generated in the Selected DDS page.
    Selected DDS

    Notice that all the new keywords were created with a condition of 60. (The DSPATR(PR) was pasted with the field originally).

  8. Now let's try it out! From the Select named indicator sets list, select All indicators are off.
    Indicators Off
    Wow! This really works!
  9. From the Select named indicator sets list, select Not found.

    The field appears red and reverse imaged.

You have added error handling to the position to employee name field and you are ready to begin Exercise 7.10: Accessing field properties.