接口日志处理类

类:ZCL_IFLOG_UTILITIES

属性:AUTH_RESULTS_LIST

类型:

TY_AUTH_RESULT    Private

受保护部分:

  PRIVATE SECTION.

    TYPES: BEGIN OF ty_auth_result,
             funcname TYPE ztall_logcfg-funcname,
             pass     TYPE abap_bool,
           END OF ty_auth_result.

    CLASS-DATA: auth_results_list TYPE HASHED TABLE OF ty_auth_result WITH UNIQUE KEY funcname.

方法:

RE_PROCESS    Static Method    Public
IS_PRD    Static Method    Public
GET_DISTINCT_COUNT    Static Method    Public
FM_AUTHORITY_CHECK    Static Method    Public

方法:RE_PROCESS

参数:

UUID    Importing    Type    SYSUUID_C32

  METHOD re_process.
    DATA: data_ref TYPE REF TO data.

    SELECT SINGLE uuid, funcname, import, change_in, table_in
      FROM ztall_iflog
      WHERE uuid = @uuid
      INTO @DATA(record).
    IF sy-subrc <> 0.
      RETURN.
    ENDIF.

    SELECT funcname, paramtype, pposition, parameter, structure
      FROM fupararef
      WHERE funcname = @record-funcname
      INTO TABLE @DATA(parameters_tab).
    IF sy-subrc <> 0.
      RETURN.
    ENDIF.

    DATA: temp_dd04l TYPE STANDARD TABLE OF dd04l.
    LOOP AT parameters_tab ASSIGNING FIELD-SYMBOL(<ptab>).
      IF strlen( <ptab>-structure ) > 30.
        CONTINUE.
      ENDIF.
      temp_dd04l = VALUE #( BASE temp_dd04l ( domname = <ptab>-structure ) ).
    ENDLOOP.

    IF temp_dd04l IS NOT INITIAL.
      SELECT domname FROM dd04l
        FOR ALL ENTRIES IN @temp_dd04l
        WHERE domname = @temp_dd04l-domname
        INTO TABLE @DATA(data_elements).
    ENDIF.

    DATA: func      TYPE string,
          ptab      TYPE abap_func_parmbind_tab,
          ptab_line TYPE abap_func_parmbind,
          etab      TYPE abap_func_excpbind_tab,
          etab_line TYPE abap_func_excpbind.

    LOOP AT parameters_tab ASSIGNING FIELD-SYMBOL(<parameter>).

      CLEAR ptab_line.
      ptab_line-name = <parameter>-parameter.
      ptab_line-kind = COND #( WHEN <parameter>-paramtype = 'E' THEN abap_func_importing
                               WHEN <parameter>-paramtype = 'I' THEN abap_func_exporting
                               WHEN <parameter>-paramtype = 'T' THEN abap_func_tables
                               WHEN <parameter>-paramtype = 'C' THEN abap_func_changing
                               ELSE                                  ''
      ).

      DATA(json_field_name) = COND string( WHEN ptab_line-kind = abap_func_exporting THEN 'IMPORT'
                                           WHEN ptab_line-kind = abap_func_tables    THEN 'TABLE_IN'
                                           WHEN ptab_line-kind = abap_func_changing  THEN 'CHANGE_IN'
                                           ELSE                                           ''
      ).

      IF json_field_name IS INITIAL.
        CONTINUE.
      ENDIF.

      ASSIGN COMPONENT json_field_name OF STRUCTURE record TO FIELD-SYMBOL(<json_raw>).
      IF sy-subrc <> 0 OR <json_raw> IS INITIAL.
        CONTINUE.
      ENDIF.

      DATA(json_data) = zcl_iflog_json=>generate_new( json = <json_raw> ).
      ASSIGN json_data->* TO FIELD-SYMBOL(<json_data>).


      ASSIGN COMPONENT <parameter>-parameter OF STRUCTURE <json_data> TO FIELD-SYMBOL(<parameter_val>).
      IF sy-subrc <> 0.
        CONTINUE.
      ENDIF.

      IF ptab_line-kind = abap_func_exporting OR ptab_line-kind = abap_func_changing.

        CREATE DATA data_ref TYPE (<parameter>-structure).
        FIELD-SYMBOLS: <temp> TYPE any.
        ASSIGN <parameter_val>->* TO <temp>.

      ENDIF.

      IF ptab_line-kind = abap_func_tables.
        "不知道为什么,如果是表类型的时候会报错,改成和changing一样的方式试运行一下
        DATA(structure_type) = CAST cl_abap_structdescr( cl_abap_datadescr=>describe_by_name( <parameter>-structure ) ).
        DATA(table_type)     = CAST cl_abap_tabledescr( cl_abap_tabledescr=>create( structure_type ) ).
        CREATE DATA data_ref TYPE HANDLE table_type.
        ASSIGN <parameter_val>->* TO <temp>.

*        CREATE DATA data_ref TYPE (<parameter>-structure).
*        ASSIGN <parameter_val>->* TO <temp>.

      ENDIF.

      IF data_ref IS BOUND.
        ASSIGN data_ref->* TO FIELD-SYMBOL(<data_ref>).
      ENDIF.

      IF line_exists( data_elements[ domname = <parameter>-structure ] ).
        <data_ref> = <temp>.
      ELSE.
        DATA(json_temp) = zcl_iflog_json=>serialize( data = <parameter_val> ).
        zcl_iflog_json=>deserialize( EXPORTING json = json_temp CHANGING data = <data_ref> ).
      ENDIF.

      GET REFERENCE OF <data_ref> INTO ptab_line-value.

      INSERT ptab_line INTO TABLE ptab.

    ENDLOOP.

    etab_line-name = 'OTHERS'.
    etab_line-value = 2.
    INSERT etab_line INTO TABLE etab.

    CALL FUNCTION record-funcname
      PARAMETER-TABLE
      ptab
      EXCEPTION-TABLE
      etab.

  ENDMETHOD.

方法:IS_PRD

参数:RESULT    Returning    Type    ABAP_BOOL

  METHOD is_prd.
    DATA: role TYPE t000-cccategory.

    CALL FUNCTION 'TR_SYS_PARAMS'
      IMPORTING
        system_client_role = role
      EXCEPTIONS
        no_systemname      = 1
        no_systemtype      = 2
        OTHERS             = 3.
    IF sy-subrc <> 0.
* Implement suitable error handling here
    ENDIF.

    IF role = 'P'.
      result = abap_true.
    ENDIF.

  ENDMETHOD.

方法:GET_DISTINCT_COUNT

参数:

TAB_DATA    Importing    Type    ANY TABLE
FIELD_NAME    Importing    Type    CLIKE
COUNT    Returning    Type    INT4

  METHOD get_distinct_count.

    TYPES: BEGIN OF ty_temp,
             field TYPE string,
           END OF ty_temp.
    DATA: count_table TYPE HASHED TABLE OF ty_temp WITH UNIQUE KEY field,
          count_wa    LIKE LINE OF count_table.

    LOOP AT tab_data ASSIGNING FIELD-SYMBOL(<wa>).
      ASSIGN COMPONENT field_name OF STRUCTURE <wa> TO FIELD-SYMBOL(<field>).
      IF sy-subrc <> 0.
        RETURN.
      ELSE.
        count_wa-field = <field>.
        INSERT count_wa INTO TABLE count_table.
      ENDIF.
    ENDLOOP.

    count = lines( count_table ).

  ENDMETHOD.

方法:FM_AUTHORITY_CHECK

参数:

FM_NAME    Importing    Type    RS38L_FNAM                                                                                                                                        
BUFFER    Importing    Type    ABAP_BOOL    ABAP_TRUE
PASS    Returning    Type    ABAP_BOOL                                                                                                                                        

  METHOD fm_authority_check.

    DATA: auth_result LIKE LINE OF auth_results_list.

    IF buffer = abap_true.
      auth_result = VALUE #( auth_results_list[ funcname = fm_name ] OPTIONAL ).
      IF auth_result IS NOT INITIAL.
        pass = auth_result-pass.
        RETURN.
      ENDIF.
    ENDIF.

    IF auth_result IS INITIAL.

      DELETE auth_results_list WHERE funcname = fm_name.
      SELECT SINGLE no_auth_check FROM ztall_logcfg WHERE funcname = @fm_name
        INTO @DATA(no_auth_check) BYPASSING BUFFER.

      IF no_auth_check = abap_true.
        auth_result = VALUE #( funcname = fm_name pass = abap_true ).
      ELSE.
        DATA: wa_tadir TYPE tadir,
              area     TYPE sobj_name.

        SELECT SINGLE area FROM enlfdir WHERE funcname = @fm_name INTO @area.
        IF sy-subrc <> 0.
          RETURN.
        ENDIF.

        CALL FUNCTION 'TR_TADIR_INTERFACE'
          EXPORTING
            wi_test_modus     = ' '
            wi_read_only      = 'X'
            wi_tadir_pgmid    = 'R3TR'
            wi_tadir_object   = 'FUGR'
            wi_tadir_obj_name = area
          IMPORTING
            new_tadir_entry   = wa_tadir
          EXCEPTIONS
            OTHERS            = 1.

        IF sy-subrc <> 0 OR wa_tadir-devclass IS INITIAL.
          AUTHORITY-CHECK OBJECT 'S_DEVELOP'
                 ID 'DEVCLASS' DUMMY
                 ID 'OBJTYPE' FIELD 'FUGR'
                 ID 'OBJNAME' FIELD area
                 ID 'P_GROUP' DUMMY
                 ID 'ACTVT' FIELD '16'.
        ELSE.
          AUTHORITY-CHECK OBJECT 'S_DEVELOP'
                 ID 'DEVCLASS' FIELD wa_tadir-devclass
                 ID 'OBJTYPE' FIELD 'FUGR'
                 ID 'OBJNAME' FIELD area
                 ID 'P_GROUP' DUMMY
                 ID 'ACTVT' FIELD '16'.
        ENDIF.
        IF sy-subrc = 0.
          auth_result = VALUE #( funcname = fm_name pass = abap_true ).
        ELSE.
          auth_result = VALUE #( funcname = fm_name pass = abap_false ).
        ENDIF.

      ENDIF.
    ENDIF.

    pass = auth_result-pass.

    INSERT auth_result INTO TABLE auth_results_list.

  ENDMETHOD.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值