Sie sind auf Seite 1von 10

2397528 - Modification: OData Hooks for SAP Gateway Logging

Manual implementation of OData Hooks for SAP Gateway Logging for SAP BASIS 7.50, 7.51, 7.52,...

The implementation of the OData hooks for UI Logging on SAP BASIS >= 7.50 can only be done via manual implementation. The coding may
slightly differ between the SAP BASIS releases of 7.50, 7.51 and 7.52. Therefore, this instruction should be seen rather as a guideline so find the
appropriate code line where the hooks are going to be implemented. The hooks, i.e. the modifications, are marked in yellow.
Method /IWBEP/CL_MGW_LOCAL_HANDLER  GET_ENTITY_SET
...
        " Process Read Entity Set
        CALL BADI mo_mgw_runtime->/iwbep/if_mgw_core_srv_runtime~read_entityset
          EXPORTING
            iv_entity_name           = ls_request_context-target_entity
            iv_source_name           = ls_request_context-source_entity
            is_paging                = ls_paging
            it_order                 = ls_request_context-order
            it_filter_select_options = ls_request_context-filter_select_options
            is_request_details       = ls_request_context
          CHANGING
            ct_headers               = et_custom_header
            cr_entityset             = er_entityset
            cr_deleted_entityset     = er_deleted_entityset
            cs_response_context      = es_response_context
            ct_inline_info           = et_inline_info
            cv_response_body         = ev_response_body.

        IF mv_batch_deferred_resp_crea EQ abap_false.

          IF  es_response_context-is_not_modified NE /iwbep/if_mgw_core_types=>gcs_modification_status-is_not_modified.
            IF mo_ral_rt_facade IS BOUND.
              mo_ral_rt_facade->log_read_access( er_entityset ).
            ENDIF.
          ENDIF.
*--------------------------------   START of Hook  for OData  -----------------------------*
*          Call Hook for OData Logging
          IF er_entityset IS BOUND.
            CALL FUNCTION '/LOGWIN/HOOK_ODATA'
              EXPORTING
                iv_odata_source = 'GES'           "GET_ENTITY_SET"
                is_context      = is_request_context
                ir_odata        = er_entityset.
          ENDIF.
*--------------------------------   END  of Hook for OData -------------------------------*

          es_response_context-is_cache_hit     = mo_sutil_runtime->is_cache_hit( ).
          es_response_context-is_cache_hit_shm = mo_sutil_runtime->is_cache_hit_shm( ).

          /iwbep/cl_mgw_handler_util=>fill_inner_error_for_header(
            EXPORTING
              iv_system_alias = ls_request_context-system_alias_info-system_alias
            CHANGING
              cs_msg_canister = es_message_container ).

        ELSE.
Method /IWBEP/CL_MGW_LOCAL_HANDLER  GET_ENTITY_TYPE
       ... 
" Process Read Entity
        CALL BADI mo_mgw_runtime->/iwbep/if_mgw_core_srv_runtime~read_entity
          EXPORTING
            iv_entity_name      = ls_request_context-target_entity
            iv_source_name      = ls_request_context-source_entity
            is_request_details  = ls_request_context
          CHANGING
            ct_headers          = et_custom_header
            cr_entity           = er_entity
            cs_response_context = es_response_context
            ct_expand_skiptoken = et_expand_skiptoken
            ct_inline_info      = et_inline_info.

        IF mv_batch_deferred_resp_crea EQ abap_false.

          check_and_raise_et_no_content(
            EXPORTING
              ir_entity                    = er_entity
              is_request_context           = ls_request_context
            CHANGING
              cs_response_context          = es_response_context ).

          IF  es_response_context-is_not_modified NE /iwbep/if_mgw_core_types=>gcs_modification_status-is_not_modified
          AND es_response_context-no_content      NE abap_true.
            IF mo_ral_rt_facade IS BOUND.
              mo_ral_rt_facade->log_read_access( er_entity ).
            ENDIF.
          ENDIF.
*--------------------------------   START of Hook  for OData  -----------------------------*
*          Call Hook for OData Logging
          IF er_entity IS BOUND.
            CALL FUNCTION '/LOGWIN/HOOK_ODATA'
              EXPORTING
                iv_odata_source = 'GET'           "GET_ENTITY_TYPE"
                is_context      = is_request_context
                ir_odata        = er_entity.
          ENDIF.
*--------------------------------   END  of Hook for OData -------------------------------*

          /iwbep/cl_mgw_handler_util=>fill_inner_error_for_header(
            EXPORTING
              iv_system_alias = ls_request_context-system_alias_info-system_alias
            CHANGING
              cs_msg_canister = es_message_container ).

        ELSE.
Method /IWBEP/CL_MGW_LOCAL_HANDLER  CREATE_ENTITY_TYPE
     ...
" Process Create Entity
        CALL BADI mo_mgw_runtime->/iwbep/if_mgw_core_srv_runtime~create_entity
          EXPORTING
            iv_entity_name      = ls_request_context-target_entity
            iv_source_name      = ls_request_context-source_entity
            io_data_provider    = lo_entry_provider
            is_request_details  = ls_request_context
          CHANGING
            ct_headers          = et_custom_header
            cr_entity           = er_entity
            cs_response_context = es_response_context
            ct_inline_info      = et_inline_info.

        " Last operation
        IF mv_changeset_op_last = abap_true.

          " Deferred Processing: Process now!
          IF mv_changeset_defer_mode = abap_true.
            CALL BADI mo_mgw_runtime->/iwbep/if_mgw_core_srv_runtime~changeset_process
              CHANGING
                ct_changeset_data = mt_changeset_defer_data.
          ELSE.
            changeset_deactivate_watchdog( ).
          ENDIF.

          " End Changeset
          CALL BADI mo_mgw_runtime->/iwbep/if_mgw_core_srv_runtime~changeset_end.
        ENDIF.

        " Deferred processing
        IF mv_changeset_defer_mode = abap_true.
          IF mv_is_shortcut = abap_true.
            add_defer_performance_data(
              EXPORTING
                iv_time_start  = lv_time_start
                iv_method_name = gcs_method_name-create_entity_type
            ).
          ENDIF.
          RETURN.
        ENDIF.

        " Raise an exception with HTTP Status 500 if no business data returned
        IF er_entity IS NOT BOUND.
          RAISE EXCEPTION TYPE /iwbep/cx_mgw_tech_exception
            EXPORTING
              textid           = /iwbep/cx_mgw_tech_exception=>no_business_data_returned
              http_status_code = /iwbep/cx_mgw_tech_exception=>gcs_http_status_codes-internal_server_error.
        ENDIF.

        IF er_entity IS BOUND.
          IF mo_ral_rt_facade IS BOUND.
            mo_ral_rt_facade->log_read_access( er_entity ).
          ENDIF.
        ENDIF.
*-------------------------------  START of Hook for OData -----------------------------*
*       Call Hook for OData Logging
        IF er_entity IS BOUND.
          CALL FUNCTION '/LOGWIN/HOOK_ODATA'
            EXPORTING
              iv_odata_source       = 'CET'           "CREATE_ENTITY_TYPE"
              is_context            = is_request_context
              ir_odata              = er_entity.
        ENDIF.
*--------------------------------  END of Hook for OData -------------------------------*

        /iwbep/cl_mgw_handler_util=>fill_inner_error_for_header(
          EXPORTING
            iv_system_alias = ls_request_context-system_alias_info-system_alias
          CHANGING
            cs_msg_canister = es_message_container
        ).

      CATCH /iwbep/cx_mgw_busi_exception /iwbep/cx_mgw_tech_exception INTO lx_exception.
Method /IWBEP/CL_MGW_LOCAL_HANDLER  EXECUTE_OPERATION
     ...
        " Process Execute  Action
        CALL BADI mo_mgw_runtime->/iwbep/if_mgw_core_srv_runtime~exec_service_operation
          EXPORTING
            iv_action_name      = lv_action_name
            iv_return_type      = ls_request_context-target_entity
            iv_multiplicity     = lv_multiplicity    "will  be determined  in /IWBEP/CL_MGW_ABS_DATA
            is_request_details  = ls_request_context
          CHANGING
            ct_headers          = et_custom_header
            cr_data             = er_data
            cs_response_context = es_response_context
            ct_inline_info      = et_inline_info.

        " Last operation
        IF mv_changeset_op_last = abap_true.

          "  Deferred Processing: Process now!
          IF mv_changeset_defer_mode = abap_true.
            CALL BADI mo_mgw_runtime->/iwbep/if_mgw_core_srv_runtime~changeset_process
              CHANGING
                ct_changeset_data = mt_changeset_defer_data.
          ELSE.
            changeset_deactivate_watchdog( ).
          ENDIF.

          "  End Changeset
          CALL BADI mo_mgw_runtime->/iwbep/if_mgw_core_srv_runtime~changeset_end.
        ENDIF.

        " Deferred processing
        IF mv_changeset_defer_mode = abap_true.
          IF mv_is_shortcut = abap_true.
            add_defer_performance_data(
              EXPORTING
                iv_time_start  = lv_time_start
                iv_method_name = gcs_method_name-execute_operation
            ).
          ENDIF.
          RETURN.
        ENDIF.

        IF mo_ral_rt_facade IS BOUND AND er_data IS BOUND.
          mo_ral_rt_facade->log_read_access( er_data ).
        ENDIF.
*--------------------------------   START of Hook  for OData  -----------------------------*
*        Call Hook for OData Logging
        IF er_data IS BOUND.
          CALL FUNCTION '/LOGWIN/HOOK_ODATA'
            EXPORTING
              iv_odata_source       = 'EO'           "EXECUTE_OPERATION"
              is_context            = is_request_context
              ir_odata              = er_data.
        ENDIF.
*--------------------------------   END  of Hook for OData -------------------------------*

        /iwbep/cl_mgw_handler_util=>fill_inner_error_for_header(
          EXPORTING
            iv_system_alias = ls_request_context-system_alias_info-system_alias
          CHANGING
            cs_msg_canister = es_message_container
        ).

      CATCH /iwbep/cx_mgw_busi_exception /iwbep/cx_mgw_tech_exception INTO lx_exception.
Method /IWBEP/CL_MGW_ABS_DATA  POST_PROCESS_READ_ENTITYSET
     ...
**********************************************************************
*      Serialize via ST
**********************************************************************
      IF io_request_obj->/iwbep/if_mgw_req_entityset~get_deltatoken( ) IS INITIAL.
        lv_request_service_name = ls_request_context-request_service_name.
        IF lv_request_service_name IS INITIAL.
          lv_request_service_name = ls_request_context-service_doc_name.
        ENDIF.
        IF ls_request_context-request_service_name IS INITIAL OR
           ( ls_request_context-request_service_name = ls_request_context-service_doc_name ).
          serialize_with_transformation(
            EXPORTING
              is_request_details           = ls_request_context
              is_response_context          = cs_response_context
              iv_service_doc_name          = lv_request_service_name
              io_request                   = io_request_obj
              io_model                     = io_model
              iv_expand_string             = lv_expand_string
              io_expand_root               = io_expand_root
              iv_generate_sts              = iv_generate_sts
              iv_sts_are_ready_to_use      = iv_sts_are_ready_to_use
            IMPORTING
              ev_successful_serialized     = lv_successful_serialized
            CHANGING
              cr_entityset                 = cr_entityset
              cv_response_body             = cv_response_body  ).
        ENDIF.
      ENDIF.

      IF lv_successful_serialized = abap_true .
        ASSIGN cr_entityset->* TO <lt_source_table>.
        cs_response_context-is_target_format = abap_true.
        ASSIGN cr_entityset->* TO <lt_source_table>.
        cs_response_context-st_entityset_count = lines( <lt_source_table> ).
        cs_response_context-st_response_size = xstrlen( cv_response_body ).
*--------------------------------   START of Hook  for OData  -----------------------------*
*        Call Hook for OData Logging
        IF cr_entityset IS BOUND.
          CALL FUNCTION '/LOGWIN/HOOK_ODATA'
            EXPORTING
              iv_odata_source = 'GET'           "GET_ENTITY_TYPE"
              is_context      = ls_request_context
              ir_odata        = cr_entityset.
        ENDIF.
*--------------------------------   END  of Hook for OData -------------------------------*
        CLEAR cr_entityset.

Das könnte Ihnen auch gefallen