cancel
Showing results for 
Search instead for 
Did you mean: 

data duplication

Former Member
0 Kudos

hello,

this is jagadeesh kumar, i have a problem like ..in my application when the end user opens a browser 4 times ( same application).and i have a approve button in it.when end user enters same data in all the four browsers and hits BUTTON APPROVE same time four records are created . now the data is duplicating.how to lock the user for approving only from single browser at a time...

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Thanks for your suggestions It works fine now.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Normally you create a lock object in the data dictionary. This will generate ENQUEUE and DEQUEUE function modules in order to form record locking. You can read more about the locking concept here:

http://help.sap.com/saphelp_nw70ehp1/helpdata/en/41/7af4c5a79e11d1950f0000e82de14a/frameset.htm

and here:

http://help.sap.com/saphelp_nw70ehp1/helpdata/en/47/daeac909dd3020e10000000a42189d/frameset.htm

This is not a Web Dynpro ABAP specific approach. This same concept for lock objects has existed in ABAP for quite some time is widely used in SAPGUI and Web Dynpro based applications (and just about everything else).

Former Member
0 Kudos

Hi,

Yes , from abap dictionary side the solution is ok for locking.But in web dynpro we are using bapi for posting data.

when user opens a browser and prresed 'ok' button the transaction runs while in the mean time if the browser again opens another browser and presses 'ok' --again the transaction runs and updates the table.so,how we can solove this .

ChrisPaine
Active Contributor
0 Kudos

Hi,

as per Thomas's suggestion - create a lock object for your session/data.

on start up of the session create a lock entry for the key piece of data that you are updating. If the lock cannot be obtained - show a message and disable the 'OK' button.

Then you can be sure only one user at a time can be doing an update.

Former Member
0 Kudos

Yeah but in my case what happening is....

when a user opens a session and he forgets it and again opens another session .Now we have two session opened.okk

Now the user pressing the 'ok' button in the two sessions opened.then int he database two records are created.

I THINK NOW YOU UNDERSTOOD MY problem.please advice me accordingly.

TomVanDoo
Active Contributor
0 Kudos

how about:

Right before you call the bapi, check if a record has been created already for this approval step

if yes: ERROR MESSAGE

if no: call bapi

ChrisPaine
Active Contributor
0 Kudos

If you checked for an exclusive lock of the object on opening each and every session the user would not be able to create data in two sessions - as the second session would not allow maintenance.

Note how you cannot maintain the same personnel number, cost centre etc in two sessions using GUI even if it is the same user - apply the same logic to your application.

0 Kudos

Hi Thomas,

I have a question. Is there way in which I do a read lock for whole table & then convert that read lock into write lock for individual keys? Optimistic lock helps partially because we can use it only when we specify same lock argument while requesting read lock & converting it to write lock.

You may as why i need such an option, consider pseudocode below

Step1. Select 100 entries from the table X

.........

Step2. Update 1 non key field of 5 rows in internal table

.......

Step3. Update these 5 rows in DB table from internal table

Here I do not want anyone else to update the 5 rows between step 1 & 3 but i cannot lock only these 5 rows (Using optimistic lock) as i don't know which one i really need to change.  Locking the entries just before step 2 is also not good as someone might have changed entries in DB table after step 1 but before step 2.

-Vishwas