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 object

Former Member
0 Likes
630

Hi all

I have created a code which uploads the data to database from local file.

Am using GUI_UPLOAD function module. At the end, program will generate a serial number.

Am using lock object to lock the data base, to avoid over writing of data in a single serial number when 2 or more user executing same program,

My query is “ <b>is this method which i adopted to overcome this problem is correct OR is there any other method I can adopt, so that more then one user store the data in different serial number at the same time.</b>

Regards.

Prajwal.k

4 REPLIES 4
Read only

Former Member
0 Likes
549

if u are uploading the data with the key fields then SAP it self maintains the consistency and no records will be overwritten...

so u dont need to lock the database...

reward points if useful......

Read only

Former Member
0 Likes
549

Hi,

SAP Locks

To complement the database changes that are made in a single database LUW, the R/3 System contains a lock mechanism, fully independent of database locks, that allows you to set a lock that spans several dialog steps. These locks are known as SAP locks.

The SAP lock concept is based on lock objects. Lock objects allow you to set an SAP lock for an entire application object. An application object consists of one or more entries in a database table, or entries from more than one database table that are linked using foreign key relationships.

Before you can set an SAP lock in an ABAP program, you must first create a lock object in the ABAP Dictionary. A lock object definition contains the database tables and their key fields on the basis of which you want to set a lock. When you create a lock object, the system automatically generates two function modules with the names ENQUEUE_<lock object name> and DEQUEUE_<lock object name> . You can then set and release SAP locks in your ABAP program by calling these function modules in a CALL FUNCTION statement.

You can create this in SE11--> Lock Object

Regards,

JLN

Read only

0 Likes
549

Hi Lakshminarayanan .

i have already created lock object. please go through my query,

regards

prajwal

Read only

Former Member
0 Likes
549

Hi Prajwal,

You could try optimistic locks.... (row level lock and not table level)

A transaction can set an optimistic lock for a table row (data record). The database system informs the transaction of the current version number of the table row.

Each time a table row is changed, the database system increases the version number. By comparing the original and the current version number, database applications can determine whether the data read while setting the lock is still current or must be read again.

To get an optimistic lock, you have to request it explicitly with the LOCK statement. If an exclusive lock already exists for a database object, you cannot set an optimistic lock (lock collision). If an optimistic lock exists for a database object, other users can continue to set exclusive, shared, or additional optimistic locks.

Before a transaction can change a table row for which it has set an optimistic lock, the database system checks whether the table row has been changed by another user since the optimistic lock was set.

· If the table row has not been changed, the database system first converts the optimistic lock into an exclusive lock, and makes the changes.

· If another transaction has changed the table row in the meantime, the database system rejects the change and releases the optimistic lock.

regards,

Karen