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: 

Object locked after commit and wait

Former Member
0 Kudos

Dear experts,

We are using MPLAN_MANUAL_CALL function to manual call a maintenance plan.

We are doing this in a loop, that calls the function more then once with the same maint. plan (we want to schedule more then one call)

The first call in the loop goes fine, but the second returns an error that the maint. plan object is locked.

We tried using commit and wait after calling the function with no help. (tried Bapi_Transaction_commit as well - same results)

We used delay (3 seconds) and it works. but this solution is bad...

How can we wait for the function to release the object?

Thank you!

5 REPLIES 5

TuncayKaraca
Active Contributor
0 Kudos

Hi Mezamer,

First find what the lock object is, once you lock the object you can use SM21 transaction to see the locks.

You can use following function modules to understand that there is lock for the object and lock object in WHILE loop. Once there is no lock anymore, you can go ahead and call next function module.

  • ENQUEUE_READ
  • ENQUE_READ
  • ENQUE_READ2

LOOP...

WHILE is locked.

Check locked.

ENDWHILE

CALL FUNCTION 'MPLAN_MANUAL_CALL'

ENDLOOP.

matt
Active Contributor
0 Kudos

If you build your update into the same update task as is doing the changes you're waiting for, then there is no issue with locking. Otherwise, you just have to do the wait - check - wait loop until it is unlocked.

Former Member
0 Kudos

Hi,

Use like the following,

LOOP.

  DO 10 TIMES.

     CALL FUNCTION MPLAN_MANUAL_CALL.

     IF SY-SUBRC  = 0.

       EXIT.

     ENDIF.

  ENDDO.

ENDLOOP.

rene_libbert
Explorer
0 Kudos

maybe something like this helps?

REPORT yrltest01.

*----------------------------------------------------------------------*

*       CLASS lcl_event_handler DEFINITION

*----------------------------------------------------------------------*

*

*----------------------------------------------------------------------*

CLASS lcl_event_handler DEFINITION.

   PUBLIC SECTION.

     TYPE-POOLS: abap.

     CLASS-DATA:

       gv_wait    TYPE abap_bool.

     CLASS-METHODS:

       handle_transaction_finished FOR EVENT transaction_finished OF cl_system_transaction_state

       IMPORTING kind,

       set_handler,

       wait_until_trans_finished.

ENDCLASS.                    "lcl_event_handler DEFINITION

*----------------------------------------------------------------------*

*       CLASS lcl_event_handler IMPLEMENTATION

*----------------------------------------------------------------------*

*

*----------------------------------------------------------------------*

CLASS lcl_event_handler IMPLEMENTATION.

   METHOD handle_transaction_finished.

     CHECK kind EQ cl_system_transaction_state=>commit_work.

     gv_wait = abap_false.

   ENDMETHOD.                    "handle_transaction_finished

   METHOD set_handler.

     SET HANDLER lcl_event_handler=>handle_transaction_finished.

     gv_wait = abap_true.

   ENDMETHOD.                    "set_handler

   METHOD wait_until_trans_finished.

    while gv_wait EQ abap_true.

        wait up to '0.2' seconds.

    endwhile.

   ENDMETHOD.                    "wait_until_trans_finished

ENDCLASS.                    "lcl_event_handler IMPLEMENTATION

END-OF-SELECTION.

   DO 3 TIMES.

     lcl_event_handler=>set_handler( ).

     CALL FUNCTION 'XYZ'

       IN UPDATE TASK

       .

     COMMIT WORK AND WAIT.

     lcl_event_handler=>wait_until_trans_finished( ).

   ENDDO.

marcin_cholewczuk
Active Contributor
0 Kudos

Hi Mezamer,

I don't know how FM MPLAN_MANUAL_CALL works, but since you're trying to use BAPI_COMMIT I'm guessing this is somehowe connected to BAPI.

Maybe you could try using command SET UPDATE TASK LOCAL You have to call it before you execute this FM and after every COMMIT WORK if you want to use within next LUV.

Best Regards

Marcin Cholewczuk