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 object

Former Member
0 Kudos
924

hi,

When i create a lock object ( E) and then use them in a report ( Se38) but when i check with SM12 , the table is not lock but i saw the lock object with the Report name .. This means that although i have executed the ENQUEUE_* but the table is not locked...

Howerver when i test the FM ENQUEUE_ in SE37 the table is locked ...

What happens and what is the difference between calling lock from Report (SE38) and from SE37

Thanks

1 ACCEPTED SOLUTION

Former Member
0 Kudos
194

Hi Qui,

you need to find small difference when the program SE38 for lock object.

-- suppose if you execute the program while in change mode then the it lock the program which it means it lock the program not table.

-- suppose if you run the program while in display mode then you cant get the lock the program in SM12.

you can also test youself,what u need to be done, go to program in chage mode press F8 then see program should lock. And if u run the program in disply mode u cant get locked the program.

<b>remember one thing, if SM12 lock the program means the program is in change mode meanch some one is doing changes</b>.

but if you run the SE37 its lock the table.

Hope u understood the differnces between them.

<b>Reward with points if useful.</b>

Regards,

Vijay

7 REPLIES 7

Former Member
0 Kudos
194

It sounds like your code to call the ENQUEUE_* is not correct. The lock you are seeing with the report name is due to the fact you are editing the program when you test it, you would see this even if your report wasn't trying to lock anything else.

Check your report code and make sure you are calling the ENQUEUE_* module in the same way as you are through se37.

Regards,

Nick

0 Kudos
194

Thank you for your helpful answer ,

But i have checked and to call the ENQUEUE in the report , i used "Pattern" and leave all the params unchanged , the code of the FM as below:

This code was generated automatically when i create lock object for the table SBOOK

And when i execute with SE37 , it locks SBOOK , but when i execute in a report , there is a lock entry in SM12 , howerver instead of the table name SBOOK , it was the name of the report which call the FM ...

FUNCTION ENQUEUE_EZ_SBOOK.

*"----


""Local Interface:

*" IMPORTING

*" VALUE(MODE_SBOOK) TYPE ENQMODE DEFAULT 'E'

*" VALUE(MANDT) TYPE SBOOK-MANDT DEFAULT SY-MANDT

*" VALUE(CARRID) TYPE SBOOK-CARRID OPTIONAL

*" VALUE(CONNID) TYPE SBOOK-CONNID OPTIONAL

*" VALUE(FLDATE) TYPE SBOOK-FLDATE OPTIONAL

*" VALUE(BOOKID) TYPE SBOOK-BOOKID OPTIONAL

*" VALUE(X_CARRID) DEFAULT SPACE

*" VALUE(X_CONNID) DEFAULT SPACE

*" VALUE(X_FLDATE) DEFAULT SPACE

*" VALUE(X_BOOKID) DEFAULT SPACE

*" VALUE(_SCOPE) DEFAULT '2'

*" VALUE(_WAIT) DEFAULT SPACE

*" VALUE(_COLLECT) TYPE DDENQCOLL DEFAULT ' '

*" EXCEPTIONS

*" FOREIGN_LOCK

*" SYSTEM_FAILURE

*"----


  • Generated function module for lock object EZ_SBOOK

  • Please do not modify or copy this function module

  • See ABAP Help for information on the SAP lock concept

  • for key word 'ENQUEUE'

DATA: __seqta_tab TYPE SEQTA OCCURS 01 WITH HEADER LINE,

__scope TYPE DDENQSCOPE,

__wait TYPE DDENQWAIT.

__wait = _wait.

__scope = _scope.

DATA: BEGIN OF %a_SBOOK,

  • Lock argument for table SBOOK

MANDT TYPE SBOOK-MANDT,

CARRID TYPE SBOOK-CARRID,

CONNID TYPE SBOOK-CONNID,

FLDATE TYPE SBOOK-FLDATE,

BOOKID TYPE SBOOK-BOOKID,

END OF %a_SBOOK.

  • Initialization of lock argument:

CALL 'C_ENQ_WILDCARD' ID 'HEX0' FIELD %a_SBOOK.

  • Assignment of lock parameters to lock fields:

IF NOT MANDT IS INITIAL.

MOVE MANDT TO:

%a_SBOOK-MANDT.

ENDIF.

IF NOT CARRID IS INITIAL OR

NOT x_CARRID IS INITIAL.

MOVE CARRID TO:

%a_SBOOK-CARRID.

ENDIF.

IF NOT CONNID IS INITIAL OR

NOT x_CONNID IS INITIAL.

MOVE CONNID TO:

%a_SBOOK-CONNID.

ENDIF.

IF NOT FLDATE IS INITIAL OR

NOT x_FLDATE IS INITIAL.

MOVE FLDATE TO:

%a_SBOOK-FLDATE.

ENDIF.

IF NOT BOOKID IS INITIAL OR

NOT x_BOOKID IS INITIAL.

MOVE BOOKID TO:

%a_SBOOK-BOOKID.

ENDIF.

  • Fill the lock table:

__seqta_tab-gname = 'SBOOK'.

__seqta_tab-gmode = MODE_SBOOK.

__seqta_tab-garg = %a_SBOOK.

APPEND __seqta_tab.

  • Lock assigned:

PERFORM send_enqueue(saplsena)

TABLES __seqta_tab

USING '1' __scope __wait ' ' 'EZ_SBOOK' _collect.

ENDFUNCTION.

0 Kudos
194

Hi,

Can you post the code you have in your program to call ENQUEUE_EZ_SBOOK?

Also, when you see the lock in SM12 with the program name, is it for lock object Z_SBOOK or a different lock object?

Regards,

Nick

Former Member
0 Kudos
194

Hi,

Lock objects are use in SAP to avoid the inconsistancy at the time of data is being insert/change into database.

SAP Provide three type of Lock objects.

- Read Lock(Shared Locked)

protects read access to an object. The read lock allows other transactions read access but not write access to

the locked area of the table

- Write Lock(exclusive lock)

protects write access to an object. The write lock allows other transactions neither read nor write access to

the locked area of the table.

- Enhanced write lock (exclusive lock without cumulating)

works like a write lock except that the enhanced write lock also protects from further accesses from the

same transaction.

You can create a lock on a object of SAP thorugh transaction SE11 and enter any meaningful name start with EZ Example EZTEST_LOCK.

Use: you can see in almost all transaction when you are open an object in Change mode SAP could not allow to any other user to open the same object in change mode.

Example: in HR when we are enter a personal number in master data maintainance screen SAP can't allow to any other user to use same personal number for changes.

Technicaly:

When you create a lock object System automatically creat two function module.

1. ENQUEUE_<Lockobject name>. to insert the object in a queue.

2. DEQUEUE_<Lockobject name>. To remove the object is being queued through above FM.

You have to use these function module in your program.

<b>Checking existing SAP locks</b>

In the transaction SM12 you can see all current SAP locks, they can be selected using object or user name. If you want to get that list in your ABAP, the function ENQUEUE_READ will return you a list of object locks for specific objects (that can be specified with a pattern). The function can be useful if you want to process some object without locking it, for example, with a BAPI or BDC, and you want to check whether you may do this at the moment. If the object is currently locked by another user, you can read the lock and decide what to do: wait, or just report an error.

<b>Enqueue Trace Records</b>

The following list columns are particularly relevant to enqueue trace records:

In the Basic List

Duration Runtime for the lock operation in the form milliseconds.microseconds.

Object The name of the lock object.

Oper The lock operation. For further information, refer to Lock Objects.

RC Return code.

If the value in this column is zero, the enqueue operation was successful. If it is "1", the operation was unsuccessful because the lock object or parts of it were already locked.

Rec Number of granules in the lock object.

Statement This column lists the granules for the lock request. If there is more than one, they are separated by the "|" character. The lock mode, lock table, and lock argument of each granule are listed.

See also: Lock objects.

In the Extended List

hh:mm:ss.ms The time at which the lock operation was performed, in the form hours : minutes : seconds. milliseconds.

Program Name of the ABAP program that requested the lock operation.

Curs not used.

For a more detailed analysis, use the Detailed Display of Enqueue Trace Records.

Regards,

Kumar.

varma_narayana
Active Contributor
0 Kudos
194

Hi Quo..

I got the Problem..

Once after executing the problem the Locks are release automatically.

So you need to Check the Lock entries in SM12 during the Execution of the Program itself in Debugging mode.

So Set a Break point at the ENQUEUE FM call in the Report.

So Set another Break point after the ENQUEUE FM call in the Report.

Once after the execution of the FM ENQUEUE

Goto Tcode SM12 And Check the lock entry .. you must find it now..

<b>reward if Helpful</b>

Former Member
0 Kudos
195

Hi Qui,

you need to find small difference when the program SE38 for lock object.

-- suppose if you execute the program while in change mode then the it lock the program which it means it lock the program not table.

-- suppose if you run the program while in display mode then you cant get the lock the program in SM12.

you can also test youself,what u need to be done, go to program in chage mode press F8 then see program should lock. And if u run the program in disply mode u cant get locked the program.

<b>remember one thing, if SM12 lock the program means the program is in change mode meanch some one is doing changes</b>.

but if you run the SE37 its lock the table.

Hope u understood the differnces between them.

<b>Reward with points if useful.</b>

Regards,

Vijay

Former Member
0 Kudos
194

Dear All,

I am very happy that i have received many helpful answers from you , At last i have figured out the problem.

- In fact , the lock is released automatically after we end the report ( SE38 ) , and if in change mode we see the lock of the report not the table , so here when i call the FM to enqueue and the the next statement is to write out something and then i went to SM12 to check , the lock of the table appeared perfectly ...:D

So many thanks to your helpful answers ....