[ABAP] Letzter Loginzeitpunkt eines Users

DATA: it_usr TYPE STANDARD TABLE OF usr02 WITH DEFAULT KEY.

SELECT * FROM usr02 INTO TABLE it_usr UP TO 100 ROWS.

IF sy-subrc = 0.
  SORT: it_usr BY trdat DESCENDING bname ASCENDING.

  WRITE: / |USER         \| DATE       \| TIME     \| CREATED|.
  WRITE: / |-------------------------------------------------|.

  LOOP AT it_usr ASSIGNING FIELD-SYMBOL(<usr>).
    WRITE: / <usr>-bname, '|', <usr>-trdat, '|', <usr>-ltime, '|', <usr>-erdat.
  ENDLOOP.
ENDIF.

[ABAP] User auflisten, die sich in den letzten x Tagen nicht angemeldet haben

PARAMETERS: p_days TYPE i OBLIGATORY DEFAULT '90'.

START-OF-SELECTION.

  DATA: last_date TYPE d.
  DATA: it_users TYPE STANDARD TABLE OF usr02 WITH DEFAULT KEY.

  DATA(lv_erdat) = sy-datum.
  lv_erdat = lv_erdat - p_days.

* Dialognutzer ('A') lesen, die sich in den letzten x Tagen nicht angemeldet haben
  SELECT * FROM usr02 INTO TABLE @it_users
    WHERE ustyp = 'A'
      AND trdat = '00000000'
      AND erdat <= @lv_erdat.

  IF sy-subrc = 0.

    SORT: it_users BY bname.

    WRITE: / |USER         \| LAST LOGIN \| CREATED|.

    ULINE.

    LOOP AT it_users ASSIGNING FIELD-SYMBOL(<u>).
      WRITE: / <u>-bname, '|', <u>-trdat, '|', <u>-erdat.
    ENDLOOP.

  ENDIF.