Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Data Interfaces and Communication Interfaces →  ABAP Channels →  AMC - ABAP Messaging Channels 

WAIT FOR MESSAGING CHANNELS

Short Reference

Other versions: 7.31 | 7.40 | 7.54

Syntax


WAIT FOR MESSAGING CHANNELS 
        [ASYNCHRONOUS TASKS] UNTIL log_exp [UP TO sec SECONDS].

Extras

1. ... ASYNCHRONOUS TASKS

2. ... UP TO sec SECONDS

Effect

This variant of the statement WAIT can be used only in receiver programs of ABAP Messaging Channels. If a receiver for AMC messages is registered in the current program, this statement interrupts the execution of the program until the result of the logical expression log_exp is false. Any logical expression can be specified for log_exp.

If the result of log_exp is false and a receiver is registered for AMC messages, the program waits until a callback routine is executed for a message sent by a sender program and checks the logical expression again. If the result of the logical expression is true or the callback routines of all messages sent previously have been executed, program execution is continued with the statement that follows WAIT. If there is no receiver for AMC, program execution is not interrupted and sy-subrc is immediately set to 4.

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 in the current program and noasynchronous function calls exist when the addition ASYNCHRONOUS TASKS is used.
8 The logical expression log_exp is false and when the UP TO addition was specified, the maximum time was exceeded.


Notes

  • If the logical expression is incorrect, the running program is stopped in its current state. After a callback routine, all data objects that were not changed in the callback routine 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.
  • The statement WAIT causes a switch in the work process, which is linked to the rollout and roll-in of all loaded programs. For this reason, the time in sec should not be set less than a second in order not to overload the system with too frequent changing of work processes.
  • Each time the statement WAIT is used, a database commit is triggered (except in updates). For this reason, WAIT must not be used between Open SQL statements that open or close a database cursor.

Example

See Receiving AMC Messages.

Addition 1

... ASYNCHRONOUS TASKS

Effect

If this addition is specified, this variant of the statement WAIT is combined with the variant WAIT FOR ASYNCHRONOUS TASKS. Program execution is continued if the logical expression is set to "true" by a callback routine for an AMC message or by an asynchronously called function. If there is no asynchronous call or no receiver is registered for AMC messages, the program is not interrupted and sy-subrc is set to 4.

Addition 2

... UP TO sec SECONDS

Effect

Specifying UP TO restricts the program interruption to a maximum number of seconds, specified in sec. For sec, a data object of type f is expected that must contain a positive number. The unit of the number in sec is seconds and the time resolution is one millisecond. After the specified time period has passed at the very latest, the program execution continues with the statement following WAIT.

Exceptions


Non-Catchable Exceptions

  • Cause: Negative time specified for sec.
    Runtime Error: WAIT_ILLEGAL_TIME_LIMIT