8/10/10

An easy way to export your user stats

All SAP Security specialists will know how to use transaction ST03N in order to export user statistics, particularly useful in Authorization Redesign projects.
This transaction is very informative yet somewhat elaborate, because you need to drill down from every instance, to every month, to every user.
Since SAPKB700 the Function Module SWNC_COLLECTOR_GET_AGGREGATES can be used to access this information all at once. See this blog for more information.
If you are authorized for SE37, you can execute this function directly. Otherwise, you need to build a little ABAP Report around it, for example this one I found on the SDN Forum:

REPORT Z_GETSTATS.
PARAMETER: day TYPE dats DEFAULT sy-datum.
DATA: t_usertcode TYPE swnc_t_aggusertcode, wa_usertcode TYPE swncaggusertcode.
START-OF-SELECTION.
CALL FUNCTION 'SWNC_COLLECTOR_GET_AGGREGATES' EXPORTING component = 'TOTAL' periodtype = 'D' periodstrt = day TABLES usertcode = t_usertcode EXCEPTIONS no_data_found = 1 OTHERS = 2.
LOOP AT t_usertcode INTO wa_usertcode.
WRITE:/ wa_usertcode-entry_id.
WRITE:/ wa_usertcode-respti, wa_usertcode-procti, wa_usertcode-cputi, wa_usertcode-dcount, wa_usertcode-ucount.
WRITE:/ '*************************************'.
ENDLOOP.


You still will have to make a selection on Date & System, but you can dowload all user data in one go.
I hope this can make life somewhat easier for you in your project.

1 comment:

Alex Ayers said...

Good tip, thanks. You can also make reading audit logs a bit more easy by using prog RSAU_SELECT_EVENTS and execute in background