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 record - Unlock record in Dialog Program

Former Member
0 Kudos
134

Dear Guys ,

i have made a custom screen that has 2 buttons that shows the previous and the next record.

IMy scanario is the following :

Two users logon to the screen and hit the previous button that shows that previous record.

The first locks the record with the Enque_...... .

How can i show the record to the second user without the message "the record is locked .....".

I try the following

CALL FUNCTION 'ENQUEUE_EYPROJECTS'
 EXPORTING
   MODE_YPROJECTS       = 'S'
   MANDT                = SY-MANDT
   BUKRS                = yprojects-bukrs
   PROJECT              = yprojects-project
*   X_BUKRS              = ' '
*   X_PROJECT            = ' '
*   _SCOPE               = '2'
*   _WAIT                = ' '
*   _COLLECT             = ' '
 EXCEPTIONS
   FOREIGN_LOCK         = 1
   SYSTEM_FAILURE       = 2
   OTHERS               = 3
          .
IF SY-SUBRC <> 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

1 ACCEPTED SOLUTION

kesavadas_thekkillath
Active Contributor
0 Kudos
97

The idea is to check if the lock already exists using ENQUEUE_READ( referring the field GTARG ) instead of trying it to lock again

4 REPLIES 4

nabheetscn
Active Contributor
0 Kudos
97

When first record is seen it is locked and when 2nd user will try to lock it this lock will fail and he will see error message.

kesavadas_thekkillath
Active Contributor
0 Kudos
98

The idea is to check if the lock already exists using ENQUEUE_READ( referring the field GTARG ) instead of trying it to lock again

0 Kudos
97

The idea is to check if the lock already exists using ENQUEUE_READ( referring the field GTARG ) instead of trying it to lock again

I don't think this is completely correct! All ENQUEUE modules have an exception FOREIGN_LOCK which is raised when lock requests are rejected.

EXPORTING
   MODE_YPROJECTS       = 'S' "--> (S)hared

OP has used the lock mode as 'S' hence requests for subsequent locks are processed successfully ->

Requests for further shared locks are accepted, even if they are issued by different users

source: SAP F1 help.

He should use the mode as (E)xclusive so that further locks for the same object are rejected.

Let me know your thoughts!

BR,

Suhas

0 Kudos
97

Suhas .. When you question it .. I always feel that there would be something in it. .Frankly speaking.. I did not notice that it was shared lock used.

He should use the mode as (E)xclusive so that further locks for the same object are rejected.

Thumbs up. Hope OP is listening what is being commented here.

Kesav