How to use the ABAP MESSAGE keyword

The effect of the ABAP message keyword is to display either the text of the short message specified in the msg field of the database table T100, or any text as a message, in the current user's login language.

The following variants are available:

  1. If neither RAISING nor INTO is specified, the statement MESSAGE interrupts program flow and sends a message. The exact behavior of the base form of the statement MESSAGE (that is, how the text is displayed and how program flow continues after the MESSAGE statement) depends on the type of message specified in msg or text, and is context-sensitive.

  2. Statement MESSAGE is supplemented with RAISING to trigger non-class-based exceptions in function modules or methods. If the exception is not handled, the message will be sent in the same way as if no RAISING complement was specified.

  3. If INTO complement is specified, program flow is not interrupted, but the short text of the message is assigned to a field.

The value of the corresponding system variable after the MESSAGE keyword is executed:
sy-msgid: After sending a message, it contains the message category, and contains the value "00" after sending any text.
sy-msgno: After sending a message, include the message number, and include the value "001" after sending any text.
sy-msgty: Contains the identifier of the message type used when sending a message or text.
sy-msgv1 to sy-msgv4: After sending the message, contain in order the contents of the data objects specified after the WITH complement. Contains the first 200 characters of the data object text after any text is sent.

Messages sent without using either of RAISING or INTO supplement are a way to interact with the user. Except for messages of type "X", the statement MESSAGE shall only be used in the presentation logic layer and shall not be used in the application logic layer.

If the text environment is set with the SET LOCALE statement, this setting is ignored for the language in which messages are displayed.

When using DISPLAY LIKE dtypethe variant , when this complement is used, the icon for the message type specified in dtype will be displayed instead of the associated icon. dtype is expected to be a character-like data object containing one of the uppercase letters "A", "E", "I", "S", or "W".

For messages that are displayed in dialogs by default, the short text will still be displayed as a dialog. If dtype contains "A" or "I", messages of type "E" or "W" (except those of PBO and LOAD-OF-PROGRAM) will be displayed as dialog windows. Messages of type "S" are always shown in the status bar, regardless of dtype. The same is true for PBO and LOAD-OF-PROGRAM messages of type "I". Messages of type "X" always raise a runtime error.

Guess you like

Origin blog.csdn.net/i042416/article/details/131286738