Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Data Interfaces and Communication Interfaces →  RFC - Remote Function Call →  CALL FUNCTION - RFC →  CALL FUNCTION - STARTING NEW TASK 

WAIT FOR ASYNCHRONOUS TASKS

Short Reference

Other versions: 7.31 | 7.40 | 7.54

Syntax


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

Extras

1. ... MESSAGING CHANNELS

2. ... UP TO sec SECONDS

Effect

This variant of the statement WAIT is designed only for use after an asynchronous RFC with callback routines. In the event of an asynchronous function call, the statement interrupts program execution for as long as the result of the logical expression log_exp remains false. Any logical expression can be specified for log_exp.

If the result of log_exp is false and there is an asynchronous function call, the program waits until a callback routine of a previous function (called asynchronously) has been executed and then checks the logical expression again. If the result of the logical expression is true or the callback routines of all functions called asynchronously beforehand have been executed, program execution is continued with the following statement in WAIT: If there is no asynchronous function call, 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 the current program does not contain any asynchronous function calls, and no receiver is registered forAMC messages for the use of the MESSAGING CHANNELS addition.
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.
  • We recommend that you always program the time for executing the callback routine of an asynchronous RFC using WAIT FOR ASYNCHRONOUS TASKS to avoid relying on the next implicit change in the work process.
  • 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.
  • This statement has an obsolete short form, in which FOR ASYNCHRONOUS TASKS is not specified.

Addition 1

... MESSAGING CHANNELS

Effect

If this addition is specified, this variant of the statement WAIT is combined with the variant WAIT FOR MESSAGING CHANNELS. 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