SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Разлогинить пользователя через заданное время



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Security and Monitoring
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Sat Apr 12, 2008 2:16 pm    Post subject: Разлогинить пользователя через заданное время Reply with quote

Code:
REPORT zkick.

** Data ****************************************************************
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
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Security and Monitoring All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.