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 on Report

Former Member
0 Likes
1,308

Hi Gurus,

I have an issue here related to a report where at a given instance of time, only one instance of it has to be running. that means, if a program is executed once and is still processing, then no other user should be able to execute the program at that time, or even it should not work if the same user tries to execute the same program in a differnet session.

Plz suggest me a solution how to acheive it..

Hi Gurus,

I have an issue here related to a report where at a given instance of time, only one instance of it has to be running. that means, if a program is executed once and is still processing, then no other user should be able to execute the program at that time, or even it should not work if the same user tries to execute the same program in a differnet session.

Plz suggest me a solution how to acheive it..

8 REPLIES 8
Read only

Former Member
0 Likes
1,207

HI,

Using lock object we can do.

Regards,

Brown.

Read only

0 Likes
1,207

Hi Brown,

I guess the Lock objects concept works with the tables..

How do i achieve it for a report..

Read only

Former Member
0 Likes
1,207

Hi,

u just use set parameter and get parameter functions to solve this issue.

get the value from sap memory(get parameter) and check it if it is 'X' issue some message.if it is space make it to 'X' and write ur code.while coming out of the program set the value as space again.

rgds,

bharat.

Read only

0 Likes
1,207

Hi Bharat,

I think the Parameter ids are available only upto a user level.. not user independent.. we need it here all over in the client..

I mean to say tat.. If a user sets the parameter id in his login.. that does not apply for other users..

Read only

0 Likes
1,207

Hi,

for example you can create an own small database table and create a record in it when the report is started and delete it when it ends. If another user (or even the same) you can check if there is an entry in the table and reject the report from running....

Hope that helped a little bit...

Read only

0 Likes
1,207

Hi Stephan

Thanks for the suggestion. but I have already tried it that way but the main problem i am facing here is that If the porgram is terminating abruptly due to some reason.. The field in the table is remaining there not getting updated to inital value..

and it even restricts the normal execution of the program, when it is run again.. I hope u understand the practical problem here..

Read only

Former Member
0 Likes
1,207

Guys any ideas?? plz..

Read only

0 Likes
1,207

Hello,

i' ve got a solution to your problem. This solution is explained by Rich Heilman in an other thread "[|]".

Here a copy of the interesting post of this thread :

You can put a lock on the program inside the program, so that when it is run it puts a lock entry in SM12, then anyone trying to run it will get a message saying that the program is locked. USe the TRDIR lock object.

code

report zrich_0001 .

data: repid type sy-repid.

repid = sy-repid

call function 'ENQUEUE_E_TRDIR'

EXPORTING

    • MODE_TRDIR = 'X'*

NAME = repid

    • 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.

[/code]

Welcome to SDN

Regards,

Rich Heilman

Cordialement,

Chaouki.