Wednesday, May 16, 2012

Disable change documents for tables created using the AET

Using the Application Enhancement Tool (AET), it is quite easy to create new tables. Once you created a new table, the system will generate all required objects. One of the objects created is the Change Document Object, which is used to log all data changes.

Logging changes could be useful, but sometimes it is not necessary. Depending on the customer’s requirements, you decide whether changes should or should not be logged. This blog contains information on how to disable the creation of change documents.

Business Transaction Component

Each table created using the AET, is assigned to a Business Transaction Component. This assignment is stored in table “CRMC_OBJECTS_GEN”.


Callback Function executed during “Save”

During the “Save” process the system processes all changed objects and stores the changed data. This process is triggered by a Callback Function. These Callback Functions can be displayed via the IMG.
SPRO-->CRM-->Transactions-->Basic Settings-->Edit Event Handler Table

The function module that is assigned here contains a call to execute the “Save”.


***************************************************
* EXTENSION Tool: GENERATED CODE *
* NEVER CHANGE IT MANUALLY *
***************************************************
CALL METHOD cl_crm_component_ec=>save
  EXPORTING
   it_header_guid = it_header_guid
   iv_object_name = 'ZOBJ000002'.


Change documents created during “Save”

While executing the “Save”, the actual change documents are created in class “CL_AXT_TABLES_PERSISTENCY”, method “WRITE_CHANGEDOCUMENTS”. The screenshot below shows the Call Stack of all methods that are executed once the Callback Function is called, up to the method that creates the change documents.


Before creating the change document, class “CL_AXT_TABLES_PERSISTENCY” method “WRITE_CHANGEDOCUMENTS” first checks if change documents should be created.
CHECK mo_table_metadata->mv_chdoc_struc IS NOT INITIAL
  AND mo_table_metadata->mv_chdoc_funcname IS NOT INITIAL.
If so, it creates the change documents.
CALL FUNCTION mo_table_metadata->mv_chdoc_funcname IN UPDATE TASK
  EXPORTING
    iv_objectid = lv_objectid
    iv_tcode = lv_tcode
    iv_utime = lv_utime
    iv_udate = lv_udate
    iv_username = sy-uname
  TABLES
    it_xtab = <lt_xtab>
    it_ytab = <lt_ytab>.


Disable creation of change documents

To disable the creation of change documents, we need to delete the assignment of the function module that creates them. This assignment is stored in table “AXT_RUN_TAB_DEF” (Extensibility tables runtime Metadata), field “CHDOC_FUNCNAME”.


Since entries in this table can be edited, here we can delete the assigned function module. As a result the check in class “CL_AXT_TABLES_PERSISTENCY” method “WRITE_CHANGEDOCUMENTS” fails, so it will not create change documents again.

No comments:

Post a Comment