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: 

lock transaction

Former Member
0 Kudos

Hi all ,

any one can give me name of the function module which

can lock a particular transaction .

its urgent , any useful answer is rewarded by points .

with regards ,

Nilesh Jain .

6 REPLIES 6

Former Member
0 Kudos

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_Name and DEQUEUE_Name.

You can then set and release SAP locks in your ABAP program by calling these function modules in a CALL FUNCTION statement.

Former Member
0 Kudos

Hi ,

see below link it may give idea.

Regards,

Vishvesh

if helpful, rewards it.

Former Member
0 Kudos

hi,

u can use enqueue and dequeue Fms. the topic has already been disucssed here.

chk this:

regards,

madhu

Former Member
0 Kudos

dear friend ,

this way u can do it easily.

rewards are expected.

vivek.

Function Modules

Function modules are cross-program, reusable procedures that are organized into function groups, and whose functions are implemented between the statements FUNCTION and ENDFUNCTION. Function modules and their interfaces are created in the Function Builder.

FUNCTION

Syntax

FUNCTION func.

*"----


*" Local Interface:

*" parameter_interface

*"----


...

ENDFUNCTION.

Effect

Between the statements FUNCTION and ENDFUNCTION, the functions of a function module func are implemented in a function group. The function module and its interface are defined in the Function Builder tool. In the source code of the function module, the function module interface defined in the Function Builder is automatically displayed as parameter_interface in comment lines underneath the FUNCTION statement.

Within the function module, local data types and data objects can be declared. There is also access to the formal parameters of the function module and to the global data types and data objects of the function group. A function module is called using the statement CALL FUNCTION.

Note

The logical expression IS SUPPLIED can be used in the function module to determine whether an actual parameter has been specified for a formal parameter.

Example

Implementation of a function module that reads data in a table-type formal parameter flight_tab under the condition of an elementary formal parameter id. The parameter interface defined in the Function Builder is visible as a comment.

FUNCTION read_spfli_into_table.

*"----


*" Local Interface:

*" IMPORTING

*" VALUE(ID) LIKE SPFLI-CARRID DEFAULT 'LH '

*" EXPORTING

*" FLIGHT_TAB TYPE SPFLI_TAB

*"----


SELECT *

FROM spfli

INTO TABLE flight_tab

WHERE carrid = id.

ENDFUNCTION.

Former Member
0 Kudos

Hi,

The lock mode controls whether several users can access data records at the same time. The lock mode can be assigned separately for each table in the lock object. When the lock is set, the corresponding lock entry is stored in the lock table of the system for each table.

Access by more than one user can be synchronized in the following ways:

Exclusive lock: The locked data can only be displayed or edited by a single user. A request for another exclusive lock or for a shared lock is rejected.

Shared lock: More than one user can access the locked data at the same time in display mode. A request for another shared lock is accepted, even if it comes from another user. An exclusive lock is rejected.

Exclusive but not cumulative: Exclusive locks can be requested several times from the same transaction and are processed successively. In contrast, exclusive but not cumulative locks can be called only once from the same transaction. All other lock requests are rejected.

Creating Lock Objects : SE11 :

Select object type Lock object in the initial screen of the ABAP Dictionary, enter an object name and choose Create. The name of a lock object should begin with an E (Enqueue).

When you activate the lock object, the two function modules ENQUEUE_<lockobjectname> and DEQUEUE_<lockobjectname> are generated from its definition to set and release locks.

Example :

When booking flights it is important to prevent flights from being overbooked. For this reason, you have to lock the particular flight as well as all the bookings existing for this flight during processing. You can do this with lock object E_BOOKING.

The lock argument of table SFLIGHT thus contains the fields MANDT, CARRID, CONNID, and FLDATE. The lock argument of table SBOOK thus contains the fields MANDT, CARRID, CONNID, FLDATE, BOOKID and CUSTOMID.

Select exclusive lock mode, that is the locked data can only be displayed and edited by one user.

When the lock object is activated, the following function modules are generated from its definition:

ENQUEUE_ E_BOOKING (set locks)

ENQUEUE_ E_BOOKING (release locks)

The following example shows how function module ENQUEUE_ E_BOOKING is called.

CALL FUNCTION  u2018 ENQUEUE_E_BOOKINGu2019
Exporting
    mode_sflight   = u2018Eu2019
    mode_sbook  =  u2018Eu2019
    mandt  =  sy-mandt
    carrid  =   u2018LHu2019
    connid  =  400
    fldate  = u201819981129u2019
    bookid  = 0
    customid   = 0
    x_carrid  = u2018  u2018
    x_connid  = u2018  u2018 
    x_fldate  =  u2018  u2018
    x-bookid  = u2018  u2018 
    x_customid  = u2018  u2018
    _scope  = u20182u2019
    _wait  = u2018Xu2019
    _collect  =  u2018  u2018
Exceptions
    foreign_lock  = 1
    system_failure  = 2
    others  = 3.


CALL FUNCTION  u2018 DEQUEUE_E_BOOKINGu2019
Exporting
    mode_sflight   = u2018Eu2019
    mode_sbook  =  u2018Eu2019
    mandt  =  sy-mandt
    carrid  =   u2018LHu2019
    connid  =  400
    fldate  = u201819981129u2019
    bookid  = 0
    customid   = 0
    x_carrid  = u2018  u2018
    x_connid  = u2018  u2018 
    x_fldate  =  u2018  u2018
    x-bookid  = u2018  u2018 
    x_customid  = u2018  u2018
    _scope  = u20183u2019
    _synchron  =  u2018  u2018
    _collect  =  u2018  u2018

Deletion of Locks :

In the initial screen of the ABAP Dictionary, select object type Lock object and enter the lock object name.

Choose to find all the programs or classes that are still using the lock object. Remove the lock module calls in the objects you found.

Choose .

A dialog box appears in which you must confirm the deletion request. If the function modules belonging to the lock object are still in use in programs or classes, a corresponding warning appears. In this case you must adjust the programs or classes affected before deleting the lock object.

Hope this will clarify your doubt.

Plz reward if useful.

Thanks,

Dhanashri.