Application Development and Automation 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: 
Read only

Lock Data Before Bapi

laurent_fournier2
Contributor
0 Likes
1,935

Hello to All,

I'm facing the following problem :

I Have developed a z application that updates data via bapis.

When the user selects the appropriate data, i lock the data in order to prevent changes in the meanwhile from other users.

When the user saves the data i first unlock the objects and the call the bapis. As you understand, this technique has a flaw : If the bapi call is somehow delayed ( Because the system is compiling ) there is a gap between the unlock of the objects and the relock from within the bapi so probably an other user can edit the object and then the bapi will not be executed since it will not be able to lock the object.

So, the question is : Is there a way to pass/transfer the lock to the bapi ? In theory, the lock owner is the key to success something like this but, i can't figure it out.

The question more clearly is :

Material aaa

lock material aaa from within the z application.

call bapi to change material aaa without unlocking the material.

"Transfer" the lock to the bapi somehow by using the lock owner.

any ideas ??

8 REPLIES 8
Read only

Former Member
0 Likes
1,206

Hi

To the best of my knowledge you can use IN UPDATE TASK and pass the value 2 or 3 to the scope then this will be farwarded to the Function module also

For further info please go through the KEY word documentation of IN UPDATE TASK

regards

Ramchander Rao.K

Read only

0 Likes
1,206

In update task is not an option since the bapi is not an update function.

Read only

0 Likes
1,206

Tried also "keeping logical unit of work" when calling the bapi.. No luck !

Read only

Former Member
0 Likes
1,206

Step1) Lock record using FM or BAPI

Step2) Update the record

Step3) Unlock the record using FM or BAPI

Read only

0 Likes
1,206

I guess that you haven't understand my question..

1) Lock objects via Enqueue FM

2) Call bapi to change objects WITHOUT Unlocking

3) Unlock objects via Dequeue FM

Problem : Bapi says that data is locked by mysefl !!

Read only

0 Likes
1,206

hi Laurent Fournier

Have you solved this problem? could you please share with me how u solved...

Thanks

jai

Read only

0 Likes
1,206

Hi Laurent,

I understand your requirement, but i have a question which might help you take a different approach, the steps in your program are,

1) Lock objects via Enqueue FM

Now in step 1) when you try to lock the material "AAA", let's say it is locked by another user. What do you do?...you throw a message is locked by so and so user right?

So why don't you start from step (2) directly, in-case the material is locked, the BAPI would return the details in the "RETURNS" parameter, if it is not locked you can proceed with your changes.

2) Call bapi to change objects WITHOUT Unlocking

3) Unlock objects via Dequeue FM

Regards,

Chen

Read only

0 Likes
1,206

Dear Chen,

Logic Is :

1) start a report and enter a material number.

2) lock material

3) display data for this material.

4)edit displayed data for material ( this can take time from the end user )

5)unlock material

6) execute bapi.

So, as you understand, your proposal cannot work here since, if i let the bapi to check and lock,

the user will edit the material and probably in the end he will not be able to update the material since it will be locked from another user.

Also, the displayed data may have changed without a lock from within the z application.

Thanks .