Supported RPG Features

ERRMSG is a field-level DDS keyword carrying the message text to show when the field fails the program's validation. It is written on its own keyword line beneath the field, conditioned by an option indicator in DDS columns 7-16:

     A            QTY            3  0I  3 12
     A  50                                    ERRMSG('Quantity must be > 0' 50)

The optional second parameter is the response indicator.

While the conditioning indicator is on and the format is written, rpgc:

The response indicator is set off automatically once the record format has been read, so the message does not linger on the next display. That means the common idiom - the same indicator used both to condition the keyword and as the response indicator - is self-clearing, and the program only ever has to turn it on:

DOU *IN03 = *ON;
  EXFMT SCREEN1;              // *IN50 is off again as soon as this returns
  IF *IN03 = *OFF and QTY = 0;
    *IN50 = *ON;              // next EXFMT shows the message
  ENDIF;
ENDDO;

A WRITE displays the error the same way, but reads nothing, so it leaves the response indicator alone for the EXFMT that follows.

When several fields of one format are in error at the same time, the message line shows the message of the first field in DDS declaration order, and that field takes the cursor.

See ERRMSGID for the form that takes its text from a message file instead of from the DDS.