Show TOC

 Avoiding Pitfalls in Message Handling

This topic discusses three pitfalls that frequently arise during message handling. However, provided that you are familiar with the information in this topic, you can easily avoid each of these pitfalls.

The first pitfall occurs when an error is added to the message handler and a method is exited, but no information is provided to instruct the caller that the corresponding checks have failed. You can easily avoid this pitfall by creating an additional message handler object – although the contents of the imported message handler should not be evaluated under any circumstances, and cannot be evaluated by a typecast anyway, because the handler may already contain other messages. Under these circumstances, the most expedient solution is to insert an additional IS_OK flag (of TYPE BOOLE_D ) to indicate that processing was completed successfully. With this solution in place, the system eventually will ascertain whether the message handler and the IS_OK statement are synchronized. If this is not the case, then the system will issue an exception.

The second pitfall arises when warnings inadvertently change the control flow. Warnings, unlike errors, always enable processing to continue. Although warnings advise the user that a particular action may cause subsequent problems, warnings do not prevent the user from performing that action. Therefore, if you add a warning, you should always return with IS_OK = TRUE to ensure that your warning does not change the control flow.

The third pitfall relates to the fact that the buffer can be rolled back at any time, even if no errors are issued, and even if additional updates (for example, retrocalculation checks) are performed. Therefore, even if none of your checks fail, you must still expect that the buffer can be rolled back at any time. Thus, your check classes should refrain, for example, from using database operations, or attributes that hold an internal state that depends upon the checks, to say nothing of import/export statements, SET/GET parameters and the like.