FUNCTION zuser_login_check360.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(DTRDAT) TYPE JBNTAGE DEFAULT 360
*" EXPORTING
*" REFERENCE(EX_RETURN) TYPE ZT_USER
*"----------------------------------------------------------------------
* Data declarations
DATA: lv_last_logon_date TYPE xuldate,
lv_days TYPE vtbbewe-atage,
ls_date TYPE bapilogond,
ls_flag TYPE bapilogonx,
lt_return TYPE bapiret2_t,
lv_dat TYPE dats.
* **--- Getting the last 180 days dates
lv_dat = sy-datum - 360.
* Based on the last login date fetch the user details
SELECT bname,trdat FROM usr02
INTO TABLE @DATA(lt_user)
WHERE trdat LE @lv_dat.
IF lt_user IS NOT INITIAL.
* **--Fetch User details
SELECT bname, name_first, name_last FROM user_addr
INTO TABLE @DATA(lt_addr)
FOR ALL ENTRIES IN @lt_user
WHERE bname = @lt_user-bname.
LOOP AT lt_addr ASSIGNING FIELD-SYMBOL(<fs_user>).
**--Update user valid to date
CALL FUNCTION 'BAPI_USER_DELETE'
EXPORTING
username = <fs_user>-bname
tables
return = lt_return.
IF sy-subrc EQ 0.
APPEND INITIAL LINE TO ex_return ASSIGNING FIELD-SYMBOL(<ls_return>).
<ls_return>-username = <fs_user>-bname.
<ls_return>-firstname = <fs_user>-name_first.
<ls_return>-lastname = <fs_user>-name_last.
READ TABLE lt_return INTO DATA(ls_return) WITH KEY type = 'S'.
<ls_return>-status = 'User' && | | && <fs_user>-bname && | | && 'Deleted' .
ELSE.
<ls_return>-username = <fs_user>-bname.
<ls_return>-firstname = <fs_user>-name_first.
<ls_return>-lastname = <fs_user>-name_last.
READ TABLE lt_return INTO ls_return WITH KEY type = 'E'.
IF sy-subrc = 0.
<ls_return>-status = ls_return-message .
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
ENDFUNCTION.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
4 | |
3 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 |