How to know the current user LOGIN status in 9-Version
Below query will help you to know the Current login status of SAP users.
Version Compatible: 9 version PL-4 and above.
Use of this Query:
1. You can know which user login currently
2. If same License is using more than one person then, you develop an small application in .Net and install it in all the clients. If the user want to login its easy to check that he can login or not.
QUERY:
select UserCode ,
(select case when Action = ‘I’ then ‘OPEN’ when Action = ‘O’ then ‘CLOSED’ end from USR5 r1
where r1.UserCode = r.UserCode and r1.Date = r.Date and r1.Time = Max(r.Time)) [Login Status]
, DATE, ClientName, Max(r.Time) [Login Time]
from USR5 r where ProcName = ‘SAP Business One.exe’ and CONVERT(VARCHAR(50), r.DATE ,103) = CONVERT(VARCHAR(50), getdate() ,103)
group by
UserCode , DATE, ClientName
having MAX(time) = Max(r.Time)
OUTPUT:
Feedback comments are welcome…..
Example for Multiple DB’s
NOTE: wherever i have mentioned “Your DB Name-” there you have to change it to your correct DB name.
select ‘Your DB Name-1’ [DB Name], UserCode ,
(select case when Action = ‘I’ then ‘ACTIVE’ when Action = ‘O’ then ‘IN-ACTIVE’ else ‘IN-ACTIVE’ end
from [Your DB Name-1].dbo.USR5 r1
where r1.UserCode = r.UserCode and r1.Date = r.Date and r1.Time = Max(r.Time)) [Login Status]
, DATE, ClientName, Max(r.Time) [Login Time]
from [Your DB Name-1].dbo.USR5 r where ProcName = ‘SAP Business One.exe’ and CONVERT(VARCHAR(50), r.DATE ,103) = CONVERT(VARCHAR(50), getdate() ,103)
group by
UserCode , DATE, ClientName
having MAX(time) = Max(r.Time)
union all
select ‘Your DB Name-2’ ,UserCode ,
(select case when Action = ‘I’ then ‘ACTIVE’ when Action = ‘O’ then ‘IN-ACTIVE’ else ‘IN-ACTIVE’ end
from [Your DB Name-2].dbo.USR5 r1
where r1.UserCode = r.UserCode and r1.Date = r.Date and r1.Time = Max(r.Time)) [Login Status]
, DATE, ClientName, Max(r.Time) [Login Time]
from [Your DB Name-2].dbo.USR5 r where ProcName = ‘SAP Business One.exe’ and CONVERT(VARCHAR(50), r.DATE ,103) = CONVERT(VARCHAR(50), getdate() ,103)
group by
UserCode , DATE, ClientName
having MAX(time) = Max(r.Time)
See also:
How to Implement SAP Business One projects successfully
How to count the entries user wise. **Helpful for go live**
Thanks Prasanna. This is very helpful.
hi prasan,
Awesome!!!!
Its very helpful.
Please write more for us...
Hi Prasan
its helpful and it shown for one database it would be appreciate this query will catch all the database.
Hi Balaji,
Just add "UNION ALL" and DatabaseName.dbo in front of table name you will get the result.
However am updating the query with 2 database.
Wherever i have mentioned "Your DB Name-1" you have to change it to your correct DB name.
Try and let me know your feedback.
Hi Prasanna
Thanks for your efforts. I did what you told but i getting following error
Msg 208, Level 16, State 1, Line 1
Invalid object name 'USR5'.
I attached modified query.
select 'ST_Live', UserCode ,
(select case when Action = 'I' then 'ACTIVE' when Action = 'O' then 'IN-ACTIVE' else 'IN-ACTIVE' end from USR5 r1
where r1.UserCode = r.UserCode and r1.Date = r.Date and r1.Time = Max(r.Time)) [Login Status]
, DATE, ClientName, Max(r.Time) [Login Time]
from [ST_Live].dbo.USR5 r where ProcName = 'SAP Business One.exe' and CONVERT(VARCHAR(50), r.DATE ,103) = CONVERT(VARCHAR(50), getdate() ,103)
group by
UserCode , DATE, ClientName
having MAX(time) = Max(r.Time)
union all
select 'TT_Live' ,UserCode ,
(select case when Action = 'I' then 'ACTIVE' when Action = 'O' then 'IN-ACTIVE' else 'IN-ACTIVE' end from USR5 r1
where r1.UserCode = r.UserCode and r1.Date = r.Date and r1.Time = Max(r.Time)) [Login Status]
, DATE, ClientName, Max(r.Time) [Login Time]
from [TT_Live].dbo.USR5 r where ProcName = 'SAP Business One.exe' and CONVERT(VARCHAR(50), r.DATE ,103) = CONVERT(VARCHAR(50), getdate() ,103)
group by
UserCode , DATE, ClientName
having MAX(time) = Max(r.Time)
Regards
Balaji
What is your patch level, query will support from Version- 9
Hi Prasanna
SAP BUSINESS ONE 9.0 PL 8
Regards
Balaji
Try this below query,
Thanks!!! It was really helpful 😉
Hi sir
Thanks for your valuable efforts ....
You Blogs are helpful for me ...Thanks
i want to know the query for SAP 2007B PL:17
HI Sir
i want know Query for 2007B
please share here if you have
Hi, I've modified the query to show all users currently logged in all SAP databases. The information can be found in SBO-COMMON.dbo.srgc.
Here is the new query:
Hope it helps.
Thanks