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: 

prevent users !!

Former Member
0 Kudos

How to prevent users for running same report at same time in back ground or fore ground ? Any one have a sample code???

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Vipin,

You can quite simply use the lock object <b>ESRDIRE</b>.

<b>to lock

CALL FUNCTION 'ENQUEUE_ESRDIRE'

EXPORTING

MODE_TRDIR = 'E'

NAME = <i>Your Program name</i>

X_NAME = ' '

_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.</b>

<b>to unlock use

CALL FUNCTION 'DEQUEUE_ESRDIRE'

EXPORTING

MODE_TRDIR = 'E'

NAME = <i>Your Program name</i>

X_NAME = ' '

_SCOPE = '3'

_SYNCHRON = ' '

_COLLECT = ' '

.</b>

Hope that helps!

Rishi

<i><b>Note: the same lock object is used to lock the program from change, so for testing the code, ensure you are not in change mode for the same program</b></i>

1 REPLY 1

Former Member
0 Kudos

Hi Vipin,

You can quite simply use the lock object <b>ESRDIRE</b>.

<b>to lock

CALL FUNCTION 'ENQUEUE_ESRDIRE'

EXPORTING

MODE_TRDIR = 'E'

NAME = <i>Your Program name</i>

X_NAME = ' '

_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.</b>

<b>to unlock use

CALL FUNCTION 'DEQUEUE_ESRDIRE'

EXPORTING

MODE_TRDIR = 'E'

NAME = <i>Your Program name</i>

X_NAME = ' '

_SCOPE = '3'

_SYNCHRON = ' '

_COLLECT = ' '

.</b>

Hope that helps!

Rishi

<i><b>Note: the same lock object is used to lock the program from change, so for testing the code, ensure you are not in change mode for the same program</b></i>