2008 Jun 05 3:38 AM
I have a zprogram. I only want one user to access my tcode at one time. When user A using my tcode, user B cannot use it by prompting something like "This program is being use by another user". How to code it?
Thanks.
I have a zprogram. I only want one user to access my tcode at one time. When user A using my tcode, user B cannot use it by prompting something like "This program is being use by another user". How to code it?
Thanks.
2008 Jun 05 3:43 AM
2008 Jun 05 4:46 AM
Hello Paul,
I could not find the FM suggested and I'm not sure if there is any standard way to check this ( I don't imagine it would be simple if there is one) but here's my two cents - build a Z transparent table with a "status" field. Update the status field at the very end of your program i.e. just before it finish running. Say, update it with value 'C' (complete) and Commit Work.
At start-of-selection event of your program read the latest entry of your Z table and check if the status field equals 'C'. If its blank (space) then a user is currently running the program and you can produce an error message but if its 'C' then its not currently being run, so OK to go ahead. In the Z table its good idea to put other user info like username, date, time, program name etc. so that it becomes kind of a log for this program.
Hope this helps and please don't forget to reward points.
Cheers,
Sougata.
2008 Jun 05 5:43 AM
Hello Paul,
Try SPA/GPA parameter. E.g.
DATA: lock like sy-uname. "user name is used as a lock criteria, i.e. lock == SPACE -> nobody
"is running the program
...
...
AT SELECTION-SCREEN OUTPUT.
GET PARAMETER ID 'USE' FIELD lock.
IF lock <> SPACE.
MESSAGE E999 with 'Currently used by' lock.
ENDIF.
SET PARAMETER ID 'USE' FIELD sy-uname.
START-OF-SELECTION.
....
....
END-OF-SELECTION.
.....
.....
SET PARAMETER ID 'USE' FIELD space.The parameter id 'USE' (or your own) is maintained in the table TPARA. This prevents duplicates of e.g. 'USE'.
That's another alternative than using ENQUEUE Function modules.
Hope this helps,
Heinz
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |