Skip to Content
author's profile photo Former Member
Former Member

End A User Session via ABAP Program

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Mar 11, 2008 at 04:54 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 19, 2009 at 08:52 AM

    Use the 'TH_DELETE_MODE' function

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 11, 2008 at 04:53 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 11, 2008 at 05:01 AM

    Hi,

    Go to Transaction SM04.

    Select the user.

    And click END SESSION

    Reward if helpful.

    Regards.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 11, 2008 at 05:56 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      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.

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.