Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

wait up to n seconds

Former Member
0 Kudos

Hi folks,

question regarding the abap wait-statement. If I say WAIT UP TO 5 SECONDS, the process is not occupied and then magically re-awakes after the specified 5 seconds.

During this time - do I have some chance to find the waiting program? Background is that I had an endless loop which I could not stop since it appeared for about half a second every 5 seconds in SM50, which was too short for me to stop or debug it.

Any hints appreciated. Cheers, Nils

6 REPLIES 6

Former Member
0 Kudos

Hi,

In SM50 if you look at the status then you might get the Waiting program

Regards

Sudheer

0 Kudos

Nope, no entry in SM50 at all. As soon as the wait is over, process shows up in SM50.

The idea of the wait is to not block a process, so this is fine with me. I just need some other way to find out that someone is waiting somewhere.

Cheers,

Nils

former_member193518
Active Participant
0 Kudos

For anyone else finding this thread, you can't see the waiting program because it is rolled out of the work process until the specified time has elapsed.

The "WAIT UP TO n SECONDS." statement causes the time spent waiting to be accumulated on the "ROLL WAIT TIME" statistic on the records shown in STAD.

Happy new year.

Darryl

Clemenss
Active Contributor
0 Kudos

Hi Nils,

WAIT interrrupts the process and issues an operating system SLEEP which makes the process invisible. If it's a batch job, you can cancel it. If it's online, use SM04, soubleclick the user and delete the user session.

And: Be aware that a SLEEP closes database cursors and works as an implicit commit. Any INSERTs,  UPDATEs and DELETEs are commited to the database and can not be rolled back.


Regards


Clemens.

0 Kudos

There is no operating system sleep involved.

The WP is available to perform other work after roll-out of the user's context.

See note 1063061.

If it's a batch job, it doesn't roll-out as there is no GUI Time in batch jobs.

If it's a batch job with RFC, it just sits and waits for the RFC (stopped: RFC).

Darryl

former_member312233
Discoverer
0 Kudos

There is an elegant solution.

This code simulates a wait up but is visible in SM50. Very simple and efficient.

  method set_waiting.
    data: l_1 type timestampl,
          l_2 type timestampl,
          l_3 type timestampl.

    data: l_v1 type p decimals 3,
          l_v2 type p decimals 3.
    get time stamp field l_1.
    do.
      l_v1 = l_v2 / 5.
      get time stamp field l_2.
      l_3 = l_2 - l_1.
      if l_3 > i_seconds.
        exit.
      endif.
    enddo.
    write l_3.
  endmethod.