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: 

Report one user execution only

Former Member
0 Kudos
1,670

Hello all,

I need in a report to implement al modifiable ALV and before

the user can change it, it must be checked if no other user is editing the list.

So, how can be verify who is running a report?

Lots of thanks,

Bogdan

1 ACCEPTED SOLUTION

Former Member
0 Kudos
585

Hi,

Not sure, but one things springs into mind.

Try using the lock object ESTCVAR.

Call the ENQUEUE function when you edit the list. If the return value is not zero then someone else is using the transaction in change mode.

But this approach would not behave properly if the ALV list is different.

For example : User 1 runs the report for Company code 1000 and User 2 runs the report for Company code 2000. The above approach will lock the transaction in both the cases. If this satisfies your requirement then go ahead.

If you need a more robust locking mechanism then you'll have to call the ENQUEUE function for the individual entries on a record level.

Hope it helps,

Thanks, Debasish

11 REPLIES 11

Vinod_Chandran
Active Contributor
0 Kudos
585

Hi,

One option is to use lock entries. Create a lock entry for some dummy table and lock it whenever one user edit the ALV. If somebody else try to change the ALV, the program will lock again and fail. This way you can control it.

Thanks

Vinod

Former Member
0 Kudos
585

Hi,

I could think of only one solution for this.

You can write a form and call that in the beginning of the program to lock the program, write your own code and at the end release the lock.

But care must be taken, that the program never ends abnormally, ( because of run time error ). Otherwise no one else will be able to run the program again.

Try the code snippet given below..

PERFORM LOCK_PROGRAM.

-


program code / logic.

………

………

PERFORM UNLOCK_PROGRAM.

form lock_program.

DATA: RET_CODE TYPE I.

data: lwa_user type tfl_user.

perform check_if_locked changing ret_code.

if ret_code <> 0.

message e000 with 'Program in use!'.

exit.

else.

lwa_user-user = sy-uname.

lwa_user-start_time = sy-uzeit.

append lwa_user to gi_users.

export gi_users to database indx(kc) id 'LOCKS'.

COMMIT WORK.

ENDIF.

endform.

FORM CHECK_IF_LOCKED CHANGING FP_RET_CODE.

DATA: LI_USERS TYPE TI_USERS.

IMPORT GI_USERS TO LI_USERS FROM DATABASE INDX(KC) ID 'LOCKS'.

IF SY-SUBRC EQ 0.

FP_RET_CODE = 4.

ELSE.

FP_RET_CODE = 0.

ENDIF.

ENDFORM.

FORM UNLOCK_PROGRAM.

DELETE FROM DATABASE INDX(KC) ID 'LOCKS'.

ENDFORM.

Cheers,

Sam

Former Member
0 Kudos
585

Hi,

Another ways is using ENQUEUE_EZPROGRAM or the variable TVARV.

Cheers,

Sam

andreas_mann3
Active Contributor
0 Kudos
585

Hi Bogdan,

1) with fm ENQUEUE_ES_PROG

2) lock object (se11)

3) fm

Andreas

Former Member
0 Kudos
586

Hi,

Not sure, but one things springs into mind.

Try using the lock object ESTCVAR.

Call the ENQUEUE function when you edit the list. If the return value is not zero then someone else is using the transaction in change mode.

But this approach would not behave properly if the ALV list is different.

For example : User 1 runs the report for Company code 1000 and User 2 runs the report for Company code 2000. The above approach will lock the transaction in both the cases. If this satisfies your requirement then go ahead.

If you need a more robust locking mechanism then you'll have to call the ENQUEUE function for the individual entries on a record level.

Hope it helps,

Thanks, Debasish

0 Kudos
585

check out his thread

https://www.sdn.sap.com/sdn/collaboration.sdn?node=linkFnode6-1&contenttype=url&content=https://

Using the solution in the thread mentioned, you can lock the report itself.

Regards

Raja

0 Kudos
585

Thanks all for answers,

And another question, How to find how lock an object?

Lots of tahnks agian

Bogdan

0 Kudos
585

Sorry my english is bad

I meant which user blocked the object.

0 Kudos
585

If answered please close the thread &

For another question create new thread.

regds

gv

0 Kudos
585

Hi,

You can find out the name of the user holding the lock by looking at system variable SY-MSGV1.

Svetlin

Former Member
0 Kudos
585

Hi,

Use lock object ES_PROG and the relevant FMs

DEQUEUE_ES_PROG - setting lock object

ENQUEUE_ES_PROG - releasing lock object

Svetlin