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: 

FM to logoff user sessions TH_DELETE_USER

Former Member
0 Kudos

Hi,

We have a requirement to develop a report program which should log off all the sessions of a specific user. We tried to use the standard FM 'TH_DELETE_USER' for this functionality but we are getting 'AUTHORITY_ERROR' when we execute this FM.

If anybody has worked on this FM and knows how to use the FM to satisfy the requirement please let us know or any other suggestions which can help us in loging off the users will be of great help.

1 ACCEPTED SOLUTION

former_member195402
Active Contributor
0 Kudos

Hi,

first you need a user who has this administration authorities.

Then you have to get some informations about servers and users, e.g.:

*    Get server list
call function 'RFC_GET_LOCAL_DESTINATIONS'
    tables
      localdest     = xt_server
    exceptions
      not_available = 1
      others        = 2.
                                                                                check sy-subrc          eq  0.
                                                                                refresh                     xt_users.
                                                                                loop                    at  xt_server.
    refresh                   xt_usrvr.
                                                                                call function 'THUSRINFO'
      destination xt_server
      tables
        usr_tabl = xt_usrvr
      exceptions
        others   = 4.
    if  sy-subrc          eq  0.
      loop                at  xt_usrvr.
        if xt_usrvr-bname in  xp_uname.
          xt_users-bname  =  xt_usrvr-bname.
          xt_users-tid    =  xt_usrvr-tid.
          xt_users-apserver  =  xt_server.
          append             xt_users.
        endif.
      endloop.
    else.
      message  w999(zz) with  text-m00
                              xt_server.
    endif.
  endloop.
                                                                                *    SORT list
  sort                        xt_users
                          by  bname
                              apserver
                              tid.
                                                                                *    delete duplicates
  delete  adjacent duplicates from xt_users
                   comparing  bname
                              apserver.

At least you have to logoff the user

call function 'TH_DELETE_USER'
    destination xt_users-apserver
    exporting
      user            = xt_users-bname
      client          = sy-mandt
    exceptions
      authority_error = 1
      others          = 2.

Regards,

Klaus

3 REPLIES 3

former_member195402
Active Contributor
0 Kudos

Hi,

first you need a user who has this administration authorities.

Then you have to get some informations about servers and users, e.g.:

*    Get server list
call function 'RFC_GET_LOCAL_DESTINATIONS'
    tables
      localdest     = xt_server
    exceptions
      not_available = 1
      others        = 2.
                                                                                check sy-subrc          eq  0.
                                                                                refresh                     xt_users.
                                                                                loop                    at  xt_server.
    refresh                   xt_usrvr.
                                                                                call function 'THUSRINFO'
      destination xt_server
      tables
        usr_tabl = xt_usrvr
      exceptions
        others   = 4.
    if  sy-subrc          eq  0.
      loop                at  xt_usrvr.
        if xt_usrvr-bname in  xp_uname.
          xt_users-bname  =  xt_usrvr-bname.
          xt_users-tid    =  xt_usrvr-tid.
          xt_users-apserver  =  xt_server.
          append             xt_users.
        endif.
      endloop.
    else.
      message  w999(zz) with  text-m00
                              xt_server.
    endif.
  endloop.
                                                                                *    SORT list
  sort                        xt_users
                          by  bname
                              apserver
                              tid.
                                                                                *    delete duplicates
  delete  adjacent duplicates from xt_users
                   comparing  bname
                              apserver.

At least you have to logoff the user

call function 'TH_DELETE_USER'
    destination xt_users-apserver
    exporting
      user            = xt_users-bname
      client          = sy-mandt
    exceptions
      authority_error = 1
      others          = 2.

Regards,

Klaus

Former Member
0 Kudos

Why not speak to your security admin about the "authority error". It seems rather obvious that the user executing the process doesn't have the necessary authorization to perform the "delete".

0 Kudos

We have copied SM04 and made it as a ZSM04 to satisfy the above requirement. The Auth issue was resolved by Basis team by adding suitable security roles.