ABAP Keyword Documentation → ABAP − Reference → Data Interfaces and Communication Interfaces → ABAP Channels → AMC - ABAP Messaging Channels
WAIT FOR MESSAGING CHANNELS
Other versions:
7.31 | 7.40 | 7.54
Syntax
WAIT FOR MESSAGING CHANNELS
[PUSH CHANNELS]
[ASYNCHRONOUS TASKS]
UNTIL log_exp [UP TO sec SECONDS].
Extras
1. ... PUSH CHANNELS
2. ... ASYNCHRONOUS TASKS
3. ... UP TO sec SECONDS
Effect
This variant of the statement WAIT
can be used only in receiver programs of
ABAP Messaging Channels. Any
logical expression
can be specified for log_exp
after UNTIL
.
-
If the result of
log_exp
is false and a receiver is registered for APC messages, the program waits until an ON_MESSAGE method is executed for a message sent by a sender program and checks the logical expression again:
- If the new check on the result of the logical expression is true,
sy-subrc
is set to 0 and the execution of the program is resumed with the statement that followsWAIT
.
- If the new check on the result of the logical expression is false and the RECEIVE methods of the previously sent messages were not all executed, one of the remaining RECEIVE methods must be executed before the program resumes.
- If the new check on the result of the logical expression is false and the RECEIVE methods of the
previously sent messages were all executed,
sy-subrc
is set to 4 and the execution of the program is resumed with the statement that followsWAIT
.
-
If the result of
log_exp
is false and there is no receiver registered for AMC messages, the execution of the program is not interrupted (regardless of the result oflog_exp
) andsy-subrc
is set to the value 4. -
If the logical expression is true, the execution of the program is not interrupted (regardless of whether a receiver is registered for AMC messages) and
sy-subrc
is set to the value 0.
If the statement WAIT
interrupts the program, the
work process is changed and a
database commit is executed (except in
updates. For this reason, WAIT
must not be used between ABAP SQL statements that open or close a
database cursor.
System Fields
sy-subrc | Meaning |
---|---|
0 | The logical expression log_exp is true. |
4 | The logical expression log_exp is false. Also, no receiver is registered for AMC messages in the current program and no registrations for APC messages orasynchronous functioncalls exist when the additions PUSH CHANNELS or ASYNCHRONOUS TASKS are used. |
8 | The logical expression log_exp is false and when the addition UP TO was specified, the maximum time was exceeded. |
Note
If the logical expression is incorrect, the running program is stopped in its current state. After a RECEIVE method, all data objects that were not changed in the RECEIVE method have the same value as when the logical expression was last evaluated. Any methods called by functions within the logical expression are executed again during the next check.
Executable Example
Addition 1
... PUSH CHANNELS
Addition 2
... ASYNCHRONOUS TASKS
Effect
If these additions are specified, this variant of the statement WAIT
is combined
with the variants WAIT FOR PUSH CHANNELS
or WAIT FOR ASYNCHRONOUS TASKS
.
The program flow described in the variants is added to the program flow described above. The WAIT
statement then also waits for APC messages or for asynchronously called functions to be called and does not just wait for AMC messages.
Addition 3
... UP TO sec SECONDS
Effect
If UP TO
is specified, a maximum time sec
can
be specified in seconds and the statement waits for AMC for this time. sec
expects a data object of the type f
that must contain a positive number. The unit of the number in sec
is seconds and the time resolution is one millisecond.
If no AMC message is received within the specified time, its RECEIVE method dictates that the result
of the logical expression log_exp
is true, sy-subrc
is set to 8, and the execution of the program is resumed with the statement that follows WAIT
.
Notes
-
If no receiver is registered for AMC messages, the addition
UP TO sec SECONDS
is ignored. -
The addition
UP TO sec SECONDS
is ignored with respect to the execution of the RECEIVE methods. The time needed for these routines to execute can be longer than the time specified.
Exceptions
Non-Handleable Exceptions
-
Cause: Negative time specified for
sec
.
Runtime error:WAIT_ILLEGAL_TIME_LIMIT