[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.

[ABAP] SAP-User zu einem Familiennamen suchen

TYPES: BEGIN OF ty_user,
         bname      TYPE usr21-bname,
         name_first TYPE adrp-name_first,
         name_last  TYPE adrp-name_last,
       END OF ty_user.

DATA: lv_nlast TYPE adrp-name_last.
DATA: it_user TYPE STANDARD TABLE OF ty_user.

SELECT-OPTIONS: so_nlast FOR lv_nlast.

START-OF-SELECTION.

  SELECT u~bname, a~name_first, a~name_last
    FROM adrp AS a
    INNER JOIN usr21 AS u
    ON a~persnumber = u~persnumber
    INTO CORRESPONDING FIELDS OF TABLE @it_user
    WHERE a~name_last IN @so_nlast.

  IF sy-subrc = 0.
    SORT: it_user BY bname.

    LOOP AT it_user ASSIGNING FIELD-SYMBOL(<fs_line>).
      WRITE: / <fs_line>-name_last, <fs_line>-name_first, <fs_line>-bname.
    ENDLOOP.
  ELSE.
    WRITE: / 'Keine Suchergebnisse.'.
  ENDIF.