Application Development 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: 

End A User Session via ABAP Program

Former Member
0 Kudos

Hi All. Does anybody know how to end/terminate a specific user’s session? Say for example, a user has 3 sessions: MM01, SE16, and SM37. I would like to end/terminate, using a program, just the MM01 session leaving the other 2 sessions active.

Regards,

RV

1 ACCEPTED SOLUTION

Former Member

Hi,

there is a command LOGOFF in abap if u execute that command u can logged out of the current user session.

or else call the function module CALL 'SYST_LOGOFF'.

example:


DATA : ANS.                                                                         
CALL FUNCTION 'POPUP_TO_CONFIRM'                                                   
     EXPORTING                                                                     
         TITLEBAR              = 'Do you really want to log off? '                 
*         DIAGNOSE_OBJECT       = ' '                                               
          TEXT_QUESTION         =                                                   
'Do you really want to log off and go home?'                                       
        TEXT_BUTTON_1         = 'Go Home'                                           
*         ICON_BUTTON_1         = ' '                                               
         TEXT_BUTTON_2         = 'Continue Working'                                 
*         ICON_BUTTON_2         = ' '                                               
*         DEFAULT_BUTTON        = '2'                                               
         DISPLAY_CANCEL_BUTTON = SPACE                                             
*         USERDEFINED_F1_HELP   = ' '                                               
         START_COLUMN          = 25                                                 
         START_ROW             = 6                                                 
*         POPUP_TYPE            =                                                   
    IMPORTING                                                                                
ANSWER                = ANS                                               
*    TABLES                                                                         
*         PARAMETER             =                                                   
     EXCEPTIONS                                                                                
TEXT_NOT_FOUND        = 1                                                 
          OTHERS                = 2.                                               
CHECK ANS = '1'.       
CALL 'SYST_LOGOFF'.   

rgds,

bharat.

8 REPLIES 8

Former Member
0 Kudos

Hi Rellie,

Have you given a thought of using the standard program 'RSM04000_ALV'.

That program displays all the users currently logged-in and the transactions they are working on.

It got many implicit enhancement points. So, for your purpose you can plug in your code in

those enhancement points.

I have not done anything similar but my guess is, it will work for this scenario.

Try to plug your code in perform build_list and complete user details will be available in the

table 'usr_tabl_alv'. This perform has got enhancement point so make use of it.

Please let me if it works for you.

Thanks & Regards,

Jallu

Former Member

Hi,

there is a command LOGOFF in abap if u execute that command u can logged out of the current user session.

or else call the function module CALL 'SYST_LOGOFF'.

example:


DATA : ANS.                                                                         
CALL FUNCTION 'POPUP_TO_CONFIRM'                                                   
     EXPORTING                                                                     
         TITLEBAR              = 'Do you really want to log off? '                 
*         DIAGNOSE_OBJECT       = ' '                                               
          TEXT_QUESTION         =                                                   
'Do you really want to log off and go home?'                                       
        TEXT_BUTTON_1         = 'Go Home'                                           
*         ICON_BUTTON_1         = ' '                                               
         TEXT_BUTTON_2         = 'Continue Working'                                 
*         ICON_BUTTON_2         = ' '                                               
*         DEFAULT_BUTTON        = '2'                                               
         DISPLAY_CANCEL_BUTTON = SPACE                                             
*         USERDEFINED_F1_HELP   = ' '                                               
         START_COLUMN          = 25                                                 
         START_ROW             = 6                                                 
*         POPUP_TYPE            =                                                   
    IMPORTING                                                                                
ANSWER                = ANS                                               
*    TABLES                                                                         
*         PARAMETER             =                                                   
     EXCEPTIONS                                                                                
TEXT_NOT_FOUND        = 1                                                 
          OTHERS                = 2.                                               
CHECK ANS = '1'.       
CALL 'SYST_LOGOFF'.   

rgds,

bharat.

Former Member
0 Kudos

Hi,

Go to Transaction SM04.

Select the user.

And click END SESSION

Reward if helpful.

Regards.

Former Member
0 Kudos

Thank you all for your prompt replies!

Hello Akshay – yes, SM04 will definitely work if you’re doing it manually. I would like to do what SM04 can do, in terminating specific sessions, but I want to do it in a program and run the program in background.

Hello Bharat –what you suggested will work but I don’t want to logoff the user. I just want to terminate one of the user’s session.

Hello Jalendhar – you’re right 'RSM04000_ALV' is the place to start. That’s where I found out that I can use a function call to 'ThUsrInfo' that will give me a list of the active users in the system with all the sessions and transactions they are using. When I tried to debug (in system mode) the part that terminates the session, it doesn’t show me the exact code that does the termination. Through further research, I found that I can use 'ThUsrInfo' with “ID 'OPCODE' FIELD opcode_delete_mode” to delete a session. My problem is I can’t seem to figure out how to control which session gets terminated.

Does anybody have an idea how to use 'ThUsrInfo' to terminate specific sessions?

Kind regards,

RV

0 Kudos

Hi RV,

Did you get the solution, I have the same issue where I want to delete a particular session. i tried using Th_USER_LIST , but it doesnt give me the list of all the sessions for a user.

former_member338933
Discoverer
0 Kudos

Use the 'TH_DELETE_MODE' function

0 Kudos

try SM12 also..and remove the lock..TCODe automatically will be removed...

0 Kudos

Hello!

I have the same problem. Please, tell me, if you have success in this part