09-20-2012 10:00 AM
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!
09-20-2012 4:18 PM
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.
LOOP...
WHILE is locked.
Check locked.
ENDWHILE
CALL FUNCTION 'MPLAN_MANUAL_CALL'
ENDLOOP.
09-21-2012 11:24 AM
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.
09-27-2012 11:00 AM
Hi,
Use like the following,
LOOP.
DO 10 TIMES.
CALL FUNCTION MPLAN_MANUAL_CALL.
IF SY-SUBRC = 0.
EXIT.
ENDIF.
ENDDO.
ENDLOOP.
09-28-2012 1:10 PM
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.
10-04-2012 9:31 PM
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