2005 Aug 25 6:13 AM
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
2005 Aug 25 6:51 AM
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
2005 Aug 25 6:37 AM
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
2005 Aug 25 6:40 AM
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
2005 Aug 25 6:43 AM
Hi,
Another ways is using ENQUEUE_EZPROGRAM or the variable TVARV.
Cheers,
Sam
2005 Aug 25 6:49 AM
2005 Aug 25 6:51 AM
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
2005 Aug 25 7:17 AM
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
2005 Aug 26 7:26 AM
Thanks all for answers,
And another question, How to find how lock an object?
Lots of tahnks agian
Bogdan
2005 Aug 26 7:29 AM
Sorry my english is bad
I meant which user blocked the object.
2005 Aug 26 7:30 AM
If answered please close the thread &
For another question create new thread.
regds
gv
2005 Aug 26 7:49 AM
Hi,
You can find out the name of the user holding the lock by looking at system variable SY-MSGV1.
Svetlin
2005 Aug 25 7:22 AM
Hi,
Use lock object ES_PROG and the relevant FMs
DEQUEUE_ES_PROG - setting lock object
ENQUEUE_ES_PROG - releasing lock object
Svetlin