按月统计tcode和report使用次数的工具

执行report,输入要查询的日期和user,

工具会按照使用次数从高到低列出输入日期所在的月份内所有该user 曾经使用过的tcode 和report list:

 

REPORT zusertcode.

 

 

PARAMETER: month TYPE dats DEFAULT sy-datum OBLIGATORY,

 

           user type usr02-bname OBLIGATORY DEFAULT sy-uname.

 

 

TYPES: BEGIN OF zusertcode,

 

         operation type char30,

 

         type type char10,

 

         count  TYPE swncshcnt,

 

       END OF zusertcode.

 

 

TYPES: tt_zusertcode TYPE STANDARD TABLE OF zusertcode WITH KEY operation type.

 

 

DATA: lt_usertcode  TYPE swnc_t_aggusertcode,

 

      wa_usertcode TYPE swncaggusertcode,

 

      wa           TYPE zusertcode,

 

      t_ut         TYPE tt_zusertcode,

 

      ls_result    TYPE zusertcode,

 

      lt_result     TYPE tt_zusertcode.

 

 

CONSTANTS: cv_tcode TYPE char30 VALUE 'Tcode',

 

           cv_report TYPE char30 VALUE 'Report',

 

           cv_count TYPE char5 value 'Count'.

 

 

START-OF-SELECTION.

 

* Set date to the first day of the month

 

  "month+6(2) = '01'.

 

  CALL FUNCTION 'SWNC_COLLECTOR_GET_AGGREGATES'

 

    EXPORTING

 

      component     = 'TOTAL'

 

      periodtype    = 'M'

 

      periodstrt    = month

 

    TABLES

 

      usertcode     = lt_usertcode

 

    EXCEPTIONS

 

      no_data_found = 1

 

      OTHERS        = 2.

 

 

  DELETE lt_usertcode WHERE tasktype <> '01'.

 

 

  LOOP AT lt_usertcode ASSIGNING FIELD-SYMBOL(<user>) WHERE account = user.

 

     CLEAR: ls_result.

 

     ls_result-operation = <user>-entry_id.

 

     ls_result-type = <user>-entry_id+72.

 

     ls_result-count = <user>-count.

 

     COLLECT ls_result INTO lt_result.

 

  ENDLOOP.

 

 

  SORT lt_result BY count DESCENDING.

 

 

  WRITE:  10 cv_tcode, 20 cv_report, 60 cv_count COLOR COL_NEGATIVE.

 

  LOOP AT lt_result ASSIGNING FIELD-SYMBOL(<result>).

 

      IF <result>-type = 'T'.

 

        WRITE: / <result>-operation COLOR COL_TOTAL UNDER cv_tcode,

 

                 <result>-count COLOR COL_POSITIVE UNDER cv_count.

 

      ELSE.

 

        WRITE: / <result>-operation COLOR COL_GROUP UNDER cv_report,

 

                 <result>-count COLOR COL_POSITIVE UNDER cv_count.

 

      ENDIF.

 

  ENDLOOP.

转载于:https://www.cnblogs.com/goodsmith/p/4874052.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值