cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

locking objects for editing via BSP

TomS2
Explorer
0 Likes
728

We have created a custom BSP-application to edit audit-objects (corrective/preventive actions). The objects are also to be edited in the SAP GUI. We need to make sure changes are not overwritten, and so need to lock the objects in some way.

We use one BAPI to read the details to display for the object, and one BAPI to execute the changes. The BAPI that executes the changes locks the object while it's changed. Editing the object in SAP GUI also locks the object.

Problem occurs with two concurrent web-users or concurrent users in SAP GUI and web. One user opens a object in the web-page and leaves it there. Meanwhile another user opens, changes and saves the object on web or in SAP GUI. The first user then executes his changes and saves them. The changes of the second user are overwritten.

I see three ways:

1/ lock the object as soon as it is viewed in web-browser, release when page is closed.

2/ compare the time the data was read into web-browser with the last time it was changed.

3/ compare the actual data when user tries to save with the actual data in the backend.

problems with these:

1/ preferred way, but can't figure out how to do it. i manage to lock (CL_CGPL_PROJECT->SET_CHANGE_MODE) the object while reading in from the backend, but the lock is gone as soon as the web-page finish execution.

2/ i don't have a last changed time, only date.

3/ a bit of a hassle as i use a free-text field mapped into a table to store in SAP. not sure if my functionality completely saves all spaces, etc...

BAPIS's used:

BAPI_BUS20370_GET_DETAIL

BAPI_BUS20370_CHANGE

appreciate any input!

View Entire Topic
Former Member
0 Likes

hi,

for your first way,

you can define a static variable (at controller if mvc or at appication class if flowlayout) say "lock_bapi" now set and reset(lock/unlock) its value when the object is viewed by user.

since it is of static type it will change accross differrent instances of page.

this is similler to handling locking manually.

in second case also,

take variables static type like "bapi_timestamp_R" "bapi_timestamp_C" put the timestamp in it of last changed and read using server clock.

now compare these values accordingly.

in third i dont think there some problem, or may be i am not clear with it.

regards.

TomS2
Explorer
0 Likes

thanx for your input.

using a static variable would solve the problem regarding concurrent updates on the web, but not when someone changes the values via SAP GUI while someone is editing via web. then i also need to implement a user-exit or something in the SAP GUI, which i really don't want to do at this stage.

#3 can probably be done, but i don't like the solution and with my current coding it could fail under certain circumstances.

peaceout

tom

Former Member
0 Likes

In this case you can use import export parameters to set an attribute.

and check its value prior to any update or so.

this way you can check it from bsp as well as from sap gui.

regards.

TomS2
Explorer
0 Likes

yeah, as i tried to say, i really don't want to do any changes to the ABAP-program that are used to update the actions in SAP. no time for it at this stage. that's why i wanna use the same locking-mechanisms that the ABAP-program is using

SergioFerrari
Active Contributor
0 Likes

Just a question: BSP application is running in the same WebAS of the SAP R/3 or is it running in a different instance?

TomS2
Explorer
0 Likes

it's running in the same instance.

i'm currently experimenting with using a stateful BSP, which certainly makes a difference regarding containing the locks. haven't sorted it completely yet, but seems to be going somewhere.

peaceout

tom

SergioFerrari
Active Contributor
0 Likes

For sure stateful will solve your problem.

sergio