How to make an abap program pause?

Igal Serban picture Igal Serban · Dec 28, 2008 · Viewed 20.5k times · Source

For testing purposes I need my ABAP program to wait for few seconds. How can this be done?

Answer

Esti picture Esti · Dec 29, 2008

2 solutions:

1) Either use WAIT UP TO ... SECONDS.

WAIT UP TO 42 SECONDS.
WAIT UP TO '0.5' SECONDS. " decimals are possible since ABAP 7.40 SP 8
  • Does a roll-out and releases the work process to the listener
  • Does an implicit Database commit

Use it when CPU processes are at a premium and when the implicit commit will not corrupt your data or cause a short dump because of an open database cursor.

2) Or use the function module ENQUE_SLEEP:

    CALL FUNCTION 'ENQUE_SLEEP'
      EXPORTING
        seconds = 42.
  • Does not release the work process
  • Does not cause an implicit Database commit

Use it when you cannot afford an implicit commit, and the system can handle the work process(es) being tied up for the duration of the SLEEP command.