Action framework BAdI Definition TRIGGER_EXECUTED

Created by Jerry Wang, last modified on May 28, 2014

可以基于该BAdI definition创建implementation来实现一些自定义逻辑:

 

Action framework BAdI Definition TRIGGER_EXECUTED

 

 

 

Action framework BAdI Definition TRIGGER_EXECUTED

 

 

指定filter的application name为CRM_ORDER, 激活BAdI implementation:

 

Action framework BAdI Definition TRIGGER_EXECUTED

 

 

在BAdI implementation的实现里会记录当前action framework处理的transaction ID和type,新建如下的message class并维护下列message 信息:

 

Action framework BAdI Definition TRIGGER_EXECUTED

 

 

在UI上修改order status触发action framework 操作之后,使用tcode SLG1查看 BAdI implementation里记录的application log是否成功保存:

 

Action framework BAdI Definition TRIGGER_EXECUTED

 

 

 

CLASS zcl_im__order_action_log DEFINITION

 

  PUBLIC

 

  FINAL

 

  CREATE PUBLIC .

 

 

  PUBLIC SECTION.

 

 

    INTERFACES if_ex_trigger_executed .

 

  PROTECTED SECTION.

 

  PRIVATE SECTION.

 

 

    DATA mv_log_handle TYPE balloghndl .

 

 

    METHODS init_log .

 

    METHODS add_log

 

      IMPORTING

 

        !iv_object_id TYPE crmd_orderadm_h-object_id

 

        !iv_obj_type  TYPE swo_objtyp .

 

    METHODS save_log .

 

ENDCLASS.

 

 

 

 

CLASS ZCL_IM__ORDER_ACTION_LOG IMPLEMENTATION.

 

 

 

* <SIGNATURE>---------------------------------------------------------------------------------------+

 

* | Instance Private Method ZCL_IM__ORDER_ACTION_LOG->ADD_LOG

 

* +-------------------------------------------------------------------------------------------------+

 

* | [--->] IV_OBJECT_ID                   TYPE        CRMD_ORDERADM_H-OBJECT_ID

 

* | [--->] IV_OBJ_TYPE                    TYPE        SWO_OBJTYP

 

* +--------------------------------------------------------------------------------------</SIGNATURE>

 

  METHOD add_log.

 

    DATA:

 

      lv_log       TYPE bal_s_msg,

 

      lv_timestamp TYPE timestampl.

 

 

    lv_log-msgid   = 'ZCM_JERRY_TEST'.

 

    lv_log-msgno   = '002'.

 

    lv_log-msgty   = 'I'.

 

 

    lv_log-msgv1 = iv_object_id.

 

    lv_log-msgv2 = iv_obj_type.

 

 

    GET TIME STAMP FIELD lv_timestamp.

 

    lv_log-time_stmp = lv_timestamp.

 

 

    CALL FUNCTION 'BAL_LOG_MSG_ADD'

 

      EXPORTING

 

        i_log_handle  = mv_log_handle

 

        i_s_msg       = lv_log

 

      EXCEPTIONS

 

        log_not_found = 1

 

        OTHERS        = 2.

 

 

    IF sy-subrc <> 0.

 

      RAISE EXCEPTION TYPE cx_fatal_exception.

 

    ENDIF.

 

  ENDMETHOD.

 

 

 

* <SIGNATURE>---------------------------------------------------------------------------------------+

 

* | Instance Public Method ZCL_IM__ORDER_ACTION_LOG->IF_EX_TRIGGER_EXECUTED~TRIGGER_EXECUTED

 

* +-------------------------------------------------------------------------------------------------+

 

* | [--->] FLT_VAL                        TYPE        PPFDAPPL

 

* | [--->] IO_TRIGGER                     TYPE REF TO CL_TRIGGER_PPF

 

* +--------------------------------------------------------------------------------------</SIGNATURE>

 

  METHOD if_ex_trigger_executed~trigger_executed.

 

    DATA:

 

      lv_ppfdtt             TYPE ppfdtt,

 

      lv_object             TYPE REF TO object,

 

      lv_context            TYPE REF TO cl_doc_context_crm_order,

 

      lv_object_guid        TYPE crmt_object_guid,

 

      lv_header_guid        TYPE crmt_object_guid,

 

      lv_object_kind        TYPE crmt_object_kind,

 

      lv_appl_object        TYPE REF TO cl_doc_crm_order,

 

      lv_object_id          TYPE crmd_orderadm_h-object_id,

 

      lv_header_object_type TYPE swo_objtyp.

 

 

    CONSTANTS:

 

      lc_ppfdappl               TYPE ppfdappl VALUE 'CRM_ORDER'.

 

 

    INCLUDE crm_object_types_con.

 

    INCLUDE crm_object_kinds_con.

 

    INCLUDE crm_objectservices_con.

 

 

    CHECK sy-uname = 'WANGJER'.

 

    CHECK flt_val EQ lc_ppfdappl .

 

 

    CALL METHOD io_trigger->get_appl

 

      RECEIVING

 

        result = lv_object.

 

 

    lv_appl_object ?= lv_object .

 

 

    CALL METHOD lv_appl_object->get_crm_obj_guid

 

      RECEIVING

 

        result = lv_object_guid.

 

 

    CALL METHOD lv_appl_object->get_crm_obj_kind

 

      RECEIVING

 

        result = lv_object_kind.

 

 

    IF lv_object_kind EQ gc_object_kind-orderadm_h .

 

      MOVE lv_object_guid TO lv_header_guid .

 

    ELSE.

 

      CALL FUNCTION 'CRM_ORDERADM_I_READ_OW'

 

        EXPORTING

 

          iv_guid        = lv_object_guid

 

        IMPORTING

 

          ev_header_guid = lv_header_guid

 

        EXCEPTIONS

 

          item_not_found = 1

 

          OTHERS         = 2.

 

      IF sy-subrc <> 0.

 

        EXIT.

 

      ENDIF.

 

 

    ENDIF.

 

 

    CALL FUNCTION 'CRM_ORDERADM_H_READ_OW'

 

      EXPORTING

 

        iv_orderadm_h_guid     = lv_header_guid

 

      IMPORTING

 

        ev_object_type         = lv_header_object_type

 

      EXCEPTIONS

 

        admin_header_not_found = 1

 

        OTHERS                 = 2.

 

    IF sy-subrc <> 0.

 

      EXIT.

 

    ENDIF.

 

 

    SELECT SINGLE object_id FROM crmd_orderadm_h INTO lv_object_id WHERE guid = lv_header_guid.

 

 

    init_log( ).

 

    add_log( iv_object_id = lv_object_id iv_obj_type = lv_header_object_type ).

 

    save_log( ).

 

  ENDMETHOD.

 

 

 

* <SIGNATURE>---------------------------------------------------------------------------------------+

 

* | Instance Public Method ZCL_IM__ORDER_ACTION_LOG->IF_EX_TRIGGER_EXECUTED~TRIGGER_EXECUTED_IN_REPORT

 

* +-------------------------------------------------------------------------------------------------+

 

* | [--->] FLT_VAL                        TYPE        PPFDAPPL

 

* | [--->] IO_TRIGGER                     TYPE REF TO CL_TRIGGER_PPF

 

* +--------------------------------------------------------------------------------------</SIGNATURE>

 

  METHOD if_ex_trigger_executed~trigger_executed_in_report.

 

  ENDMETHOD.

 

 

 

* <SIGNATURE>---------------------------------------------------------------------------------------+

 

* | Instance Private Method ZCL_IM__ORDER_ACTION_LOG->INIT_LOG

 

* +-------------------------------------------------------------------------------------------------+

 

* +--------------------------------------------------------------------------------------</SIGNATURE>

 

  METHOD init_log.

 

    DATA: ls_log_header   TYPE bal_s_log.

 

 

    ls_log_header-object = 'PPF'.

 

    ls_log_header-subobject = 'PROCESSING'.

 

 

    CALL FUNCTION 'BAL_LOG_CREATE'

 

      EXPORTING

 

        i_s_log                 = ls_log_header

 

      IMPORTING

 

        e_log_handle            = mv_log_handle

 

      EXCEPTIONS

 

        log_header_inconsistent = 1

 

        OTHERS                  = 2.

 

 

    IF sy-subrc <> 0.

 

      RAISE EXCEPTION TYPE cx_fatal_exception.

 

    ENDIF.

 

 

  ENDMETHOD.

 

 

 

* <SIGNATURE>---------------------------------------------------------------------------------------+

 

* | Instance Private Method ZCL_IM__ORDER_ACTION_LOG->SAVE_LOG

 

* +-------------------------------------------------------------------------------------------------+

 

* +--------------------------------------------------------------------------------------</SIGNATURE>

 

  METHOD save_log.

 

    DATA: lt_log_handle TYPE bal_t_logh.

 

 

    APPEND mv_log_handle TO lt_log_handle.

 

    CLEAR mv_log_handle.

 

 

    CALL FUNCTION 'BAL_DB_SAVE'

 

      EXPORTING

 

        i_t_log_handle   = lt_log_handle

 

      EXCEPTIONS

 

        log_not_found    = 1

 

        save_not_allowed = 2

 

        numbering_error  = 3

 

        OTHERS           = 4.

 

 

    IF sy-subrc <> 0.

 

      RAISE EXCEPTION TYPE cx_fatal_exception.

 

    ENDIF.

 

  ENDMETHOD.

 

ENDCLASS.

 

上一篇:mysql字段值如何区分大小写


下一篇:Document Builder: replace variable guid in merge