1. MESSAGE
xnnn.
2. MESSAGE
ID id TYPE mtype NUMBER n.
3.
MESSAGE xnnn(mid).
4. MESSAGE msg TYPE mtype.
Sends a message. Messages are stored in the table T100,
are processed using transaction SE91 and can be created by forward navigation.
The ABAP runtime environment handles messages according to the type declared in the
MESSAGE statement and the context in which the message was sent. The following message types exist:
Messages are mainly used to handle user input on screens. The following table shows the behavior of each message type in each context. An explanation of the numbers used is included at the end of the table:
A
E I S W
X
--------------------------------------------------------------
PAI Module
1 2 3 4
5 6
PAI Module for POH 1
7 3 4 7
6
PAI Module for POV 1
7 3 4 7
6
--------------------------------------------------------------
AT
SELECTION-SCREEN ... 1 8
3 4 9 6
AT SELECTION-SCREEN
for POH 1 7 3
4 7 6
AT SELECTION-SCREEN for POV 1
7 3 4 7
6
AT SELECTION-SCREEN ON EXIT 1 7 3
4 7 6
--------------------------------------------------------------
AT LINE-SELECTION
1 10 3 4 10
6
AT PFn
1 10
3 4 10 6
AT USER-COMMAND
1 10 3 4 10
6
--------------------------------------------------------------
INITIALIZATION
1 11
3 4 11 6
START-OF-SELECTION 1 11
3 4 11 6
GET
1 11 3 4 11
6
END-OF-SELECTION 1 11
3 4 11 6
--------------------------------------------------------------
TOP-OF-PAGE
1 11 3 4 11
6
END-OF-PAGE
1 11 3 4 11
6
TOP-OF-PAGE DURING ... 1 10
3 4 10 6
--------------------------------------------------------------
LOAD-OF-PROGRAM
1 1 4 4
4 6
--------------------------------------------------------------
PBO
Module
1 1 4 4
4 6
AT SELECTION-SCREEN OUTPUT 1
1 4 4 4
6
--------------------------------------------------------------
Procedure:
see
Messages
--------------------------------------------------------------
MESSAGE xnnn.
1. ... WITH
f1 ... f4
2. ...
RAISING exception
3. ...
INTO f
4. ... DISPLAY LIKE mtype
Outputs the message
nnn from the message class i
with the type
x. You must specify the message class i using
the MESSAGE-ID addition to the
REPORT statement, PROGRAM, or another introductory program statement.
MESSAGE I001.
... WITH f1 ... f4
Inserts the contents of a field fi in the message instead
of in the placeholder &i. If unnumbered variables (&)
are used in a message text, these are replaced consecutively by the fields
f1 to f4.
To
aid compilation, only numbered variables (&1 to &4) are to be used in future if several fields are involved.
If a "&" is supposed to appear in the message at runtime, you must enter
&&.
In the long text of a message, the symbol &Vi& is
replaced by the field contents of fi.
After WITH, you can specify 1 to 4 fields.
You can output up to 50 characters per field. If the field contains more characters, these are ignored.
MESSAGE E0004 WITH 'Hugo'.
When executing the statement, the contents of the fields f1
to
f4 are assigned to the system fields SY-MSGV1,
SY-MSGV2, SY-MSGV3 and SY-MSGV4.
... RAISING exception
Only possible within a function module or a method (see
FUNCTION, METHOD):
Triggers the exception exception.
If the program
calling the function module or method handles the exception itself, control returns immediately to that
program (see CALL FUNCTION
and CALL METHOD).
Only then are the current values passed from the procedure to the EXPORTING-,
CHANGING- (und RETURNING)
parameters of the function module or method, if they are specified as pass-by- reference. However, the
calling program can refer to the system field values (see above).
If the calling program does
not handle the exception itself, the message is output (see
RAISE).
You cannot use this addition in conjunction with the ... INTO cf addition.
If, during a Remote Function Call,
an error occurs in the target system, details of the error message are passed back to the calling system
in the following system fields: SY-MSGNO, SY-MSGID, SY-MSGTY, SY-MSGV1,
SY-MSGV2, SY-MSGV3, and SY-MSGV4. These fields
are initialized before every RFC. If a short dump or a type X message occurs, the short text of the
dump is transferred to the caller, and the contents of SY-MSGID,
SY-MSGTY, SY-MSGNO, and SY-MSGV1 assigned by the system.
In RFC-enabled function modules, no ABAP statements are allowed that would end the RFC connection (for example, either LEAVE or SUBMIT without the AND RETURN addition).
Example... INTO f
Instead of displaying the message, the system places the message text in the field f. The message type is not evaluated.
You cannot use this addition in conjunction with the ...RAISING exception
or the DISPLAY LIKE mtype addition. The system sets the
following system variables: SY-MSGID (message class),
SY-MSGTY (message type), SY-MSGNO
(message number) and
SY-MSGV1, SY-MSGV2,
SY-MSGV3, SY-MSGV4 (parameters).
DATA msgtext(72).
...
MESSAGE E004 WITH 'Hugo' INTO msgtext.
... DISPLAY LIKE mtype
The message display uses the icon of the message type mtype but the message is handled according to its actual type.
This addition cannot be used in conjunction with the addition ... INTO.
MESSAGE I004 DISPLAY LIKE 'E'.
MESSAGE ID id TYPE mtype NUMBER n.
1. ... WITH
f1 ... f4
2. ...
RAISING exception
3. ...
INTO f
4. ... DISPLAY LIKE mtype
The message components are set dynamically:
The addition MESSAGE-ID of the introductory program statement is not required or is overridden.
... WITH f1 ... f4
... RAISING exception
... INTO f
... DISPLAY LIKE mtype
As in variant 1.
MESSAGE ID 'SU' TYPE 'E' NUMBER '004' WITH 'Hugo'.
Outputs the message with the number 004 and MESSAGE-ID SU (see above) as an E (Error) message and replaces the first variable (&) with 'Hugo'.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
Constructs the message dynamically from the contents of the system fields
SY-MSGID, SY-MSGTY,
SY-MSGNR
,
SY-MSGV1
,SY-MSGV2,SY-MSGV3,and
SY-MSGV4. These may, for example, be set by an exception
after CALL FUNCTION or CALL TRANSACTION ... USING.
MESSAGE xnnn(mid).
1. ... WITH
f1 ... f4
2. ...
RAISING exception
3.
... INTO f
4. ... DISPLAY LIKE mtype
As in variant 1. The message class is determined by specifying mid.
The addition MESSAGE-ID of the introductory program statement is not required or is overridden.
... WITH f1 ... f4
... RAISING exception
... INTO f
... DISPLAY LIKE mtype
As in variant 1.
MESSAGE X004(SU) WITH 'Hugo'.
MESSAGE msg TYPE mtype.
1. ... RAISING exception
2. ... DISPLAY LIKE mtype
With this variant, the message can be passed directly in the form of a character-like field. The message type is specified using the required TYPE addition.
... RAISING exception
... DISPLAY LIKE mtype
As in variant 1.
MESSAGE 'File not found.' TYPE 'E'.
The text 'File not found.' is output as the error message.
Non-Catchable Exceptions
Messages