'Display file field value is not getting cleared when ERRMSG is *ON is RPG program

There is an output field(R1Msg) that shows a message to the screen. I also have a ERRMSG. In debug, I found that the ERRMSG indicator is On, but the output field R1MSG value is set to blanks. I do a write and EXFMT after this, but still when it shows the screen, R1MSG still has the previous value. Can I fix this without using a Message subfile?



Solution 1:[1]

ERRMSG does not populate the field it is attached to. Instead the message is displayed on the message line, usually line 23 for an 80 column display. However ERRMSG is a very complex keyword, and you have to be aware of all the things that cause it to be ignored, and all the things it does to the screen. The most common mistake is thinking you can change a field value in the same output that you use to indicate ERRMSG. On any output operation with one or more ERRMSG keywords activated, NO FIELDS are updated on the screen.

When a message is displayed because of either the ERRMSG or the ERRMSGID keyword, all fields on the display are kept, including the field the message is associated with. Except for option indicators, data in the output buffer is ignored (that is, any new data from the program is not sent to the display).

But the most egregious is that the keyboard is locked until the user presses the reset key.

For all errors: The message is highlighted. The cursor is blinked and the keyboard locked until the workstation user presses the Reset key.

What is that? Well, it is a special purpose key on a 5250 terminal keyboard. Similar to the windows key on modern keyboards. It is generally mapped to the left hand control key by the terminal emulator, but no modern PC keyboard has an Error Reset key.

There are more restrictions and behaviors. Best to read about them in the IBM manual here. And, if your screen is more than the simplest of screens, ERRMSG is likely going to cause you more headache than anything else. I rarely use it since message subfiles are so simple and do not have the limitations and negative impacts of ERRMSG.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 jmarkmurphy