Previous Topic: Writing and Reading in One StepNext Topic: Testing for Identical Data


Suppressing Map Error Messages

You can suppress the display of error messages for map fields. For example, you can code a data validation test so that it suppresses a map field's default error message and displays a different message when the field is in error.

What to Do

Include the ERROR MESSAGE IS ACTIVE/SUPPRESS parameter on your MODIFY MAP statement. ERROR MESSAGE immediately follows the REQUIRED/OPTIONAL parameter.

Example of Suppressing Error Messages

This COBOL example issues a MODIFY MAP statement that suppresses the display of default error messages for the ORDER-AMOUNT field on the current map.

In this application, the data validation routine compares the ORDER-AMOUNT field with the number of widgets on hand. If the current stock restricts the size of ORDER-AMOUNT, an alternative message is displayed.

  1. Define an alternative message in working storage. For example:
    DATA DIVISION.
    WORKING-STORAGE SECTION.
    01  MESSAGES.
        05 INITIAL-MESSAGE            PIC X(80) VALUE
         'ENTER A NUMERIC ORDER-AMOUNT AND PRESS ENTER'.
        05 EDIT-ERROR-MESSAGE         PIC X(80) VALUE
         'ORDER-AMOUNT EITHER NOT ENTERED OR NOT NUMERIC'.
        05 INVENTORY-MESSAGE          PIC X(80) VALUE
         'NOT ENOUGH WIDGETS IN STOCK TO DELIVER THAT AMOUNT'.
        05 DISPLAY-MESSAGE            PIC X(80) VALUE
         'CLEAR TO EXIT ** ENTER ORDER-AMOUNT AND ENTER TO CONTINUE'
    
  2. Modify the map to display alternative messages when a specific error is found:
    MODIFY MAP MAP01 TEMPORARY
       FOR DFLD ORDER-AMOUNT
           ERROR MESSAGE IS SUPPRESS.
    
  3. Perform your data validation routine. For example, you can compare the number of widgets in stock to ORDER-AMOUNT. If ORDER-AMOUNT is greater than the number in stock, issue an alternative message indicating that the order cannot be filled.

    If the data validation routine indicates that there are not enough widgets in stock, display the map with the alternative message.

TEMPORARY and PERMANENT Options

The use of the SUPPRESS option is affected by the TEMPORARY/PERMANENT option: