[ABAP] Anzahl Aufrufe von Transaktionen und Reports pro User ausgeben

Variante 1 (User, Typ, Aufrufe)

PARAMETERS: p_month TYPE dats OBLIGATORY DEFAULT sy-datum.

TYPES: BEGIN OF ty_result,
         user      TYPE sy-uname,
         operation TYPE char30,
         type      TYPE char10,
         count     TYPE swncshcnt,
       END OF ty_result.

DATA: it_result TYPE STANDARD TABLE OF ty_result WITH DEFAULT KEY.

START-OF-SELECTION.

  DATA: it_autc TYPE swnc_t_aggusertcode.

* Daten für den kompletten Monat holen
  CALL FUNCTION 'SWNC_COLLECTOR_GET_AGGREGATES'
    EXPORTING
      component     = 'TOTAL'
      periodtype    = 'M'
      periodstrt    = p_month
    TABLES
      usertcode     = it_autc
    EXCEPTIONS
      no_data_found = 1
      OTHERS        = 2.

  IF sy-subrc = 0.
* nur Tasktyp '01'
    DELETE it_autc WHERE tasktype <> '01'.

* Daten zusammenfügen
    LOOP AT it_autc ASSIGNING FIELD-SYMBOL(<u>).
      COLLECT VALUE ty_result( user      = <u>-account
                               operation = <u>-entry_id
                               type      = <u>-entry_id+72
                               count     = <u>-count ) INTO it_result.
    ENDLOOP.

* Nach User, Typ und Aufrufen sortieren
    SORT: it_result BY user type count DESCENDING.

* Daten ausgeben
    LOOP AT it_result ASSIGNING FIELD-SYMBOL(<group>) GROUP BY <group>-user ASCENDING.
      WRITE: / <group>-user.

      LOOP AT GROUP <group> ASSIGNING FIELD-SYMBOL(<u2>).
        WRITE: / <u2>-type, <u2>-operation, <u2>-count.
      ENDLOOP.

      ULINE.
    ENDLOOP.
  ENDIF.

Aufrufe Transaktionscodes pro User ermitteln

PARAMETERS: p_month TYPE swncdatum DEFAULT sy-datum.

START-OF-SELECTION.

* component: TOTAL oder Hostname
  DATA: lv_swnchostname TYPE swnchostname VALUE 'TOTAL'.
* periodtype: M - first day of month, W - first day of week
  DATA: lv_swncperitype TYPE swncperitype VALUE 'M'.
  DATA: it_swncaggusertcode TYPE STANDARD TABLE OF swncaggusertcode WITH DEFAULT KEY.

* Aggregate aus der Datenbank lesen
  CALL FUNCTION 'SWNC_COLLECTOR_GET_AGGREGATES'
    EXPORTING
      component     = lv_swnchostname
*     ASSIGNDSYS    = SY-SYSID
      periodtype    = lv_swncperitype
      periodstrt    = p_month
    TABLES
*     TASKTYPE      =
*     TASKTIMES     =
*     TIMES         =
*     DBPROCS       =
*     EXTSYSTEM     =
*     TCDET         =
*     FRONTEND      =
*     MEMORY        =
*     SPOOLACT      =
*     TABLEREC      =
      usertcode     = it_swncaggusertcode
*     USERWORKLOAD  =
*     RFCCLNT       =
*     RFCCLNTDEST   =
*     RFCSRVR       =
*     RFCSRVRDEST   =
*     SPOOL         =
*     HITLIST_DATABASE       =
*     HITLIST_RESPTIME       =
*     ASTAT         =
*     ASHITL_DATABASE        =
*     ASHITL_RESPTIME        =
*     COMP_HIERARCHY         =
*     ORG_UNITS     =
*     DBCON         =
*     VMC           =
*     WEBSD         =
*     WEBCD         =
*     WEBS          =
*     WEBC          =
*     TREX          =
    EXCEPTIONS
      no_data_found = 1
      OTHERS        = 2.

  IF sy-subrc = 0.
    cl_demo_output=>write_data( it_swncaggusertcode ).
* HTML-Daten aus itab generieren
    DATA(lv_html) = cl_demo_output=>get( ).

* Daten im Inline-Browser im SAP-Fenster anzeigen
    cl_abap_browser=>show_html( EXPORTING
                                  title        = 'TCodes'
                                  html_string  = lv_html
                                  container    = cl_gui_container=>default_screen ).

* cl_gui_container=>default_screen erzwingen
    WRITE: space.
  ENDIF.