2008 Apr 02 6:54 PM
Hello all,
I have developed a interactive Z application and I would like to add a routine to check to see if the user executing the program currently in the program in another session. Essentially I'd like to enforce one session of my program per user so if knows the code or function module to check this I would appreciate it.
Thanks!
2008 Apr 02 6:59 PM
Use FM ENQUEUE_ESINDX .
Change your program so as to call the above FM before the start of the transaction. pass the program name and RELID as 'ZZ'.
So when another user tries to run the transaction, the FM throws an error message saying "Lock not possible".
Hope this helps. Reward points if helpful.
Thanks,
Balaji
Hello all,
I have developed a interactive Z application and I would like to add a routine to check to see if the user executing the program currently in the program in another session. Essentially I'd like to enforce one session of my program per user so if knows the code or function module to check this I would appreciate it.
Thanks!
2008 Apr 02 6:59 PM
Use FM ENQUEUE_ESINDX .
Change your program so as to call the above FM before the start of the transaction. pass the program name and RELID as 'ZZ'.
So when another user tries to run the transaction, the FM throws an error message saying "Lock not possible".
Hope this helps. Reward points if helpful.
Thanks,
Balaji
2008 Apr 02 7:22 PM
Thank you for the quick answer, one point of clarification though I would to restrict this by user so if I have 15 users in the program at one time that's OK however if I want prevent a single user from have multiple instances of the same program running. Can this be accomodate via this FM?
2008 Apr 03 6:14 AM
Use FM ENQUEUE_ESINDX .
Change your program so as to call the above FM before the start of the transaction. pass a unique name and RELID as 'ZZ'.
The unique name could be the program name. Since you want to prevent single user having multiple instances of the same program running, pass the unique name (l_var) as something like this:
concatenate <program name> <username> into the l_var.Pass the l_var to the FM instead of the program name.
Hope this helps. Reward points if helpful
Thanks,
Balaji
2008 Apr 03 3:17 PM
Balaji - Do you have a small sample of code demonstrating this FM with parameters you mentioned?
2008 Apr 03 3:27 PM
Check the below code.
CALL FUNCTION 'ENQUEUE_ESINDX'
EXPORTING
MODE_INDX = 'E'
MANDT = SY-MANDT
RELID = 'ZZ'
SRTFD = <unique name> "In your case it will be username combined with program name
* SRTF2 =
* X_RELID = ' '
* X_SRTFD = ' '
* X_SRTF2 = ' '
* _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.
Hope this helps. Reward points if helpful.
Thanks,
Balaji
2008 Apr 02 7:23 PM
You can use function 'THUSRINFO', which will bring you the username and the transaction code, among other parameters. Then, before starting the report, you could check with this function if the user is already executing the transaction.
2008 Apr 03 5:20 AM
To check if program is running
SELECT COUNT( * )
INTO count
FROM tbtcp AS p INNER JOIN tbtco AS o
ON ojobname = pjobname
AND ojobcount = pjobcount
WHERE p~progname = sy-repid
AND o~delanfrep = space
AND o~status = 'R'.
IF count NE 1 = program is running
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |