on 02-25-2019 9:54 AM
Hi,
I created a method to add a WBS element to an existing project from a WBS template project. This method has an optional indicator to also copy the "Easy Cost Planning" or cost estimation from the reference WBS.
The cost can only be copied after the new WBS exists, which it's done with the BAPI_PROJECT_MAINTAIN. After the call to the BAPI I execute the BAPI_TRANSACTION_COMMIT with the WAIT parameter set and I found out that this was not enought to ensure that all the changes are commited to the database.
Then I added the method below that uses the ENQUEUE_EC_PROJS function to ensure that the WBS is really not locked. But surprisingly this is not working and the copy cost part is failing because of the data being locked or non-existing in the DB. If I execute slowly with the debugger everything works.
My last option is to just add a fix WAIT UP to X SECONDS but I don't like the idea at all. Can you think of a better solution?
METHOD wait_for_wbs_unlocked.
DATA: lv_counter TYPE i.
LOOP AT it_wbs_element ASSIGNING FIELD-SYMBOL(<ls_wbs_element>).
WHILE lv_counter < zcl_XXX=>lock_wait_limit. "Wait "limit" seconds
CALL FUNCTION 'ENQUEUE_EC_PROJS'
EXPORTING
mode_proj_enq = 'S' "Read-lock
typ = 'P' "P=WBS
pspid = <ls_wbs_element>-wbs_element
_scope = '3'
_wait = abap_true "This should already wait 5 seconds...
EXCEPTIONS
OTHERS = 1.
IF sy-subrc = 0.
CALL FUNCTION 'DEQUEUE_EC_PROJS'
EXPORTING
mode_proj_enq = 'S' "Read-lock
typ = 'P' "P=WBS, D=Project
pspid = <ls_wbs_element>-wbs_element
_scope = '3'.
lv_counter = zcl_XXX=>lock_wait_limit.
ELSE.
IF lv_counter = zcl_XXX=>lock_wait_limit.
"RAISE EXCEPTION
ELSE.
ADD 1 TO lv_counter.
WAIT UP TO 1 SECONDS.
ENDIF.
ENDIF.
ENDWHILE.
ENDLOOP.
ENDMETHOD.
Could you try to replace the ENQUEUE call with a SELECT FROM PRPS, the WAIT option should insure the lock is released if no exotic option was used in the ENQUEUE call.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
99 | |
11 | |
11 | |
6 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.