韦天飞韦天龙bl文:Message processing
来源:百度文库 编辑:九乡新闻网 时间:2024/04/29 01:15:34
Messages are single texts, stored in table T100, that you can maintain in Transaction SE91 or by forward navigation in the ABAP Workbench. T100 has the following structure:
- Language key
- Twenty-character message class
- Message number
- Message text (up to 72 characters)
Message classes assign messages to an application (maybe to a development class, for example), and the message numbers identify the individual messages within the message class. When you call a message in ABAP, you need to specify the message class and message number. The language key is supplied by the system according to the system language environment.
The MESSAGE Statement
The MESSAGE statement has three variants and several additions:
Using a Global Message Class
If the
introductory statement of a program contains the addition... MESSAGE-ID
and a message class
MESSAGE
where
Specifying the Message Statically
To specify the message class, message number, and message type statically, use the following form of the MESSAGE statement:
MESSAGE
This statement is like the first variant, but here you specify the message class
Specifying the Message Dynamically
To specify the message class, message number, and message type dynamically, use the following form of the MESSAGE statement:
MESSAGE ID
where
Filling Message Texts Dynamically
Message texts in table T100 can contain up to four ampersand characters as placeholders. You can replace these at runtime using the WITH addition in the MESSAGE statement:
MESSAGE ... WITH
The contents of fields
Messages and Exceptions
Within function modules and methods, you can use the RAISING addition in the MESSAGE statement to trigger exception:
MESSAGE..... RAISING
If the calling program does not handle the exception
Message processing depends on the message type specified in the MESSAGE statement, and the program context in which the statement occurs.
Message Types
A
Termination
The message appears in a dialog box, and the program terminates. When the user has confirmed the message, control returns to the next-highest area menu.
E
Error
Depending on the program context
I
Information
The message appears in a dialog box. Once the user has confirmed the message, the program continues immediately after the MESSAGE statement.
S
Status
The program continues normally after the MESSAGE statement, and the message is displayed in the status bar of the next screen.
W
Warning
Depending on the program context
X
Exit
No message is displayed, and the program terminates with a short dump. Program terminations with a short dump normally only occur when a runtime error occurs. Message type X allows you to force a program termination. The short dump contains the message ID.
Contexts
Messages, especially those with type E or W, are processed according to the context in which they occur. The following sections summarize the most important context rules: