Application Development and Automation 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: 
Read only

Programatically logoff a user

Former Member
1,869

Hi ,

How do we programatically logoff a user? Any FM's?

Thanks,

krishna.

1 ACCEPTED SOLUTION
Read only

former_member203501
Active Contributor
0 Likes
1,624

hi use this ..

CALL 'SYST_LOGOFF'.

this will definitely work . i tested well .

11 REPLIES 11
Read only

Former Member
0 Likes
1,624

Hello,

This is the FM: TH_DELETE_USER.

Do not use it in development systems for playing around ;-).

Hope it helps.

Cheers,

Jayant

Read only

0 Likes
1,624

does this just logoff a user or deletes the user?

I am just looking @ logoff and not deletion.

Could you calrify pls?

Thanks,

Krishna.

Read only

0 Likes
1,624

This will only logoff the user. Will not delete it.

Thanks,

Jayant

Read only

Former Member
0 Likes
1,624

Why would you want to do such a thing to a user?

Read only

0 Likes
1,624

I think he hates someone at work.!!!!!!!!! .

Read only

0 Likes
1,624

not that i hates some one......... its bussiness requirment guys!

You have an answer you are most welcome!

Read only

0 Likes
1,624

Hello,

Below code can help you,

"&----


*

"& Report Ztest *

*"& *

"&----


*

"& *

"& *

"&----


*

report Ztest.

data: opcode type x value 2.

data: begin of usr_tabl occurs 10.

include structure uinfo.

data: end of usr_tabl.

data temp_text like sm04dic-popupmsg.

data: begin of fields occurs 10.

include structure help_value.

data: end of fields.

data: begin of valuetab occurs 10,

line(80),

end of valuetab.

data: tmpuname like sy-uname.

"&Selection Screen ****************************************************

"&Kick Off User/s

selection-screen begin of block b1 with frame title text-001.

"&User Name

select-options: uname for sy-uname obligatory.

"&Client

parameters: client like t000-mandt default sy-mandt obligatory.

selection-screen skip.

"& Time To Kick User Off Until

parameters: time like sy-uzeit default sy-uzeit obligatory,

"&Interval Between Logoffs

interval(2) type n default 1 obligatory,

"& Warn User Before Kicking Off?

warn as checkbox.

selection-screen end of block b1.

"& At Selection Screen *************************************************

at selection-screen on value-request for uname-low.

perform f4_help_check_uname using uname-low.

"& Start of Selection **************************************************

start-of-selection.

do.

refresh usr_tabl.

"& Get the list of logged on users

call 'ThUsrInfo' id 'OPCODE' field opcode

id 'TAB' field usr_tabl-sys.

loop at usr_tabl where bname in uname.

"& If user/s must be warned

if not warn is initial.

concatenate 'You will be logged off from client'

client

'in 10 seconds.' into temp_text separated by space.

call function 'TH_POPUP'

exporting

client = client

user = usr_tabl-bname

message = temp_text

exceptions

user_not_found = 1

others = 2.

"& Wait 10 seconds after warning user/s

wait up to 10 seconds.

endif.

"& Kick off user/s

call function 'TH_DELETE_USER'

exporting

user = usr_tabl-bname

client = client

exceptions

authority_error = 1

others = 2.

endloop.

"&Once the specified time is reached, stop logging user/s off.

if sy-uzeit >= time.

exit.

endif.

"& Wait the specified time before logging off user/s again.

wait up to interval seconds.

enddo.

"& Forms ***************************************************************

"&

"& Form F4_HELP_CHECK_UNAME

"&----


*

"& This is to show only logged on users when F4 is pressed on

"& user name.

"&----


*

"& -->P_UNAME_LOW text

"&----


*

form f4_help_check_uname using p_uname.

clear fields.

refresh fields.

clear valuetab.

refresh valuetab.

clear usr_tabl.

refresh usr_tabl.

"&Fill the structure table

fields-tabname = 'ZTSTSTRC'.

fields-fieldname = 'NAME'.

fields-selectflag = 'X'.

append fields.

clear fields.

fields-tabname = 'ZTSTSTRC'.

fields-fieldname = 'CLIENT'.

append fields.

clear fields.

"& Get the list of logged on users

call 'ThUsrInfo' id 'OPCODE' field opcode

id 'TAB' field usr_tabl-sys.

delete usr_tabl where bname = sy-uname and mandt = sy-mandt.

delete usr_tabl where bname is initial.

sort usr_tabl by mandt bname.

delete adjacent duplicates from usr_tabl comparing bname mandt.

"& Fill the value table

loop at usr_tabl.

valuetab-line = usr_tabl-bname.

append valuetab.

valuetab-line = usr_tabl-mandt.

append valuetab.

endloop.

"& Call the help value screen

call function 'HELP_VALUES_GET_WITH_TABLE'

exporting

title_in_values_list = ''

titel = 'Online Users'

importing

select_value = tmpuname

tables

fields = fields

valuetab = valuetab.

p_uname = tmpuname.

"&Change the client number to correspond with what user name the

"& user selects.

clear client.

read table usr_tabl with key bname = tmpuname.

client = usr_tabl-mandt.

endform. " f4_help_check_uname

Hope this solved your bussiness requirement.

Thanks,

Jayant

Read only

0 Likes
1,624

nope this doesnt work. I have used this in userexit SUSR0001 ( which called whenever user logs in ).

Do we have any system calls which we can use?

Thanks,

Krishna.

Read only

0 Likes
1,624

Can't you just lock the user instead of kicking him out as soon as he logs on?

Thomas

Read only

former_member203501
Active Contributor
0 Likes
1,625

hi use this ..

CALL 'SYST_LOGOFF'.

this will definitely work . i tested well .

Read only

0 Likes
1,624

Yes this works tq.