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: 

BOPF Optimistic Locking - How is it intended to work?

former_member184711
Participant
0 Kudos

Hi,

I am a bit confused how BOPF optimistic locking is intended to work.

I know, I can lock a DB line by retrieving it

 me->o_phase_srv_mngr->retrieve(
        EXPORTING
          iv_node_key             = /cenitapm/if_bo_pw_phase_c=>sc_node-pwph
          it_key                  = t_key
          iv_edit_mode            = /bobf/if_conf_c=>sc_edit_optimistic
        IMPORTING
          eo_message              = o_message  
          et_data                 = t_pwph
      ).

And I know, I can promote the lock to an exclusive one by executing an action.

If a lock gets promoted, all other optimistic locks on that DB line are removed and can't be promoted anymore.

My problem is now: How does the BOPF behave if its optimistic lock was removed when I want to execute an action or do a modification to the DB line.

What I see is, that the BOPF simply sets a normal exclusive lock and overrides what happened in other sessions. Which leads to inconsistencies in the data.

Now my questions:

  • How is the optimistic lock intended to be used in BOPF? (The new entries in help.sap don't help here)
  • How can I explicitly promote an optimistic lock to an exclusive one (via BOPF) and be notified, that I have to reload the data?
  • (Additional Question: What is the appropriate primary tag for BOPF questions?)

Help is very much appreciated.

Regards David

6 REPLIES 6

cyclingfisch_
Active Contributor
0 Kudos

Hi David,

did you find an answer for your question already?

If I got you right, you want to promote an optimistic lock after having an exclusive one?

I would do a retrieve as you showed in your coding. But maybe I got your question wrong.

BOPF should be the right tag. But the community just starts to get alive again after the relaunch.

Cheers,

Martin

Hi,

the sequence is the following

  1. Lock object A optmisitic in session1
  2. Lock object A optmisitic in session2
  3. Change object A in session1
  4. Change object A in session2

Step 4 should fail with an error telling me, that I can't change object A, because my data is not up to date.

What actually happens is that the BOPF just creates a direct exclusive lock and writes the data. With this, the changes made in session1 are overwritten.

0 Kudos

I guess you mean "3. Change object A in session1"?

0 Kudos

Right 🙂 That was what I meant

Hi David,

your observation for the steps 1-4 would clearly indicate an error. If you have a reproducible example, you could open an incident.

What is your SAP_BASIS or SAP_BS_FND release and SP? There have been a number of SAP notes related to BOPF locking, the most important one being 2182397 (but also 2264813 may be of interest).

You may also want to check if the BO you are using has its own implementation of the LOCK action.

Regards,

Ivo

mustafa_74199
Participant
0 Kudos

Hi David,

Between steps 3 and 4, if the changing in step 3 was saved then step 4 can also be done and saved again. there is no problem. Only you should keep in mind, that fields changed in step 3 (and saved) will be also updated after step 4 (and save). If in step 3 and step 4 the same fields were changed by users, then the change which is done in step 4 will be valid.

On the other hand if user doesn't save after step 3, the other user gets an error message after attempting to perform step 4. Because right after the changing in step 3, documents are locked with Exclusive Lock anymore. Which means u r the only person who can change anything until a save action.

Best Regards

Mustafa