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: 

Close user sessions on all application Servers

techy
Explorer
0 Kudos
1,128

Hello,

i get a user list in a report:

CALL FUNCTION 'TH_USER_LIST'

     TABLES

       list          = gi_user_list

     EXCEPTIONS

       auth_misssing = 1

       OTHERS        = 2.


So I will get the user sessions which are online on the instance where I start the report. I take also the server list with  TH_SERVER_LIST and kill the users with

CALL FUNCTION 'TH_DELETE_USER'

         DESTINATION gwa_server-name

         EXPORTING

           user            = g_user

           client          = g_mand

         EXCEPTIONS

           authority_error = 1.


But if one user is only logged in an other application server he will not be killed.

Is there a solution where I can get the user list of all application servers and so I can end all the sessions? Or, is there a function module which end all sessions on all application servers?

1 ACCEPTED SOLUTION

former_member226239
Contributor
0 Kudos
432

To my knowledge the FM 'TH_USER_LIST' will give you all the users (get the list using the parameter USRLIST and not LIST from the FM) list who are logged into all the application servers (that you can see in SM51).

So, I think you are good with it. Just try and let me know.

-Chandra

8 REPLIES 8

former_member226239
Contributor
0 Kudos
433

To my knowledge the FM 'TH_USER_LIST' will give you all the users (get the list using the parameter USRLIST and not LIST from the FM) list who are logged into all the application servers (that you can see in SM51).

So, I think you are good with it. Just try and let me know.

-Chandra

0 Kudos
432

Hi chandra,

I am facing the same issue.

Not able to logh off the user when there are multiple server present in the system.

I have one internal table that is having logged in user with server name after that I am not able to log all of them. Few are getting logged but few are not.

I am using FM TH_DELETE_USER

Please help.

Jelena_Perfiljeva
Active Contributor
0 Kudos
432

Isn't there some kind of a standard functionality for this that Basis uses? Why do you need a custom report for this?

keremkoseoglu
Contributor
432

This code will do what you want:

METHOD delete_user_session.

    DATA:
      lt_servers TYPE tt_msxxlist,
      lt_uinfo   TYPE tt_uinfo,
      lt_usrlist TYPE tt_usrlist.


    CALL FUNCTION 'TH_SERVER_LIST'
      TABLES
        list           = lt_servers
      EXCEPTIONS
        no_server_list = 1
        OTHERS         = 2
        ##FM_SUBRC_OK.
  
    CALL FUNCTION 'TH_USER_LIST'
      TABLES
        list          = lt_uinfo
        usrlist       = lt_usrlist
      EXCEPTIONS
        auth_misssing = 1
        OTHERS        = 2
        ##FM_SUBRC_OK.

    LOOP AT lt_servers ASSIGNING FIELD-SYMBOL(<ls_server>).
      LOOP AT lt_usrlist
        ASSIGNING FIELD-SYMBOL(<ls_user>)
        WHERE bname EQ iv_bname.


        CALL 'ThSndDelUser'
          ID 'MANDT'  FIELD sy-mandt
          ID 'BNAME'  FIELD <ls_user>-bname
          ID 'SERVER' FIELD <ls_server>-name
          ID 'TID'    FIELD <ls_user>-tid.


      ENDLOOP.
    ENDLOOP.

  ENDMETHOD.

Complete class is available here: https://github.com/keremkoseoglu/ABAP-Library/blob/master/basis/zcl_bc_sap_system.abap

0 Kudos
432

Hi kerem,

I tried this but TH_USER_LIST is not giving all the users that are in AL08.

So I can't use this FM.

Is there any other way of doing this?

432

priya_ind if you check the code of AL08, you can see how this TCode reads the users. You can mimic that easily.

Code excerpt from SE38 - RSM04000_ALV_NEW:

FORM build_list.
  DATA: session_list TYPE ssi_session_list,
        server_info  TYPE REF TO cl_server_info.


  TRY.
      CREATE OBJECT server_info.


      IF is_system_client = 'X'.
        session_list = server_info->get_session_list( with_application_info = with_appl_info ).
      ELSE.
        session_list = server_info->get_session_list( tenant = sy-mandt with_application_info = with_appl_info ).
      ENDIF.
    CATCH cx_ssi_no_auth.
      MESSAGE e150 WITH TEXT-100.
  ENDTRY.


  SORT session_list BY tenant user_name.


  PERFORM map_session_list USING session_list
                           CHANGING session_alv_table.


ENDFORM.                    "build_list

0 Kudos
432

Hi kerem

I have used FM TH_SYSTEMWIDE_USER_LIST to fetch list of AL08 users which is working fine then I have looped that list and passed the username to fm TH_DELETE_USER to log them off but they are not getting logged off from quality as there are 2 servers but in development there is 1 server so its working completely.

Could you please provide me with the abap code to resolve this.

Thanks in advance!!

0 Kudos
432

priya_ind did you check my sample code carefully? Did you call TH_SERVER_LIST first, and loop through it?