Customer Relationship Management Blogs by SAP
Stay up-to-date on the latest developments and product news about intelligent customer experience and CRM technologies through blog posts from SAP experts.
Showing results for 
Search instead for 
Did you mean: 
Former Member

For CRM account hierarchies, we do not have a standard function/report to delete the hierarchies from the Account Hierarchy application. The reason is the hierarchies are used in several places like Territory Management, Pricing, Trade Promotion Management etc. and there is no routine available to check if the deletion can be permitted or not based on the usage.

We can only delete assignments of hierarchy nodes and business partners, as mentioned in SAP library : Working with Account Hierarchies - Business Partners - SAP Library

But if you really want to clean up CRM tables from the Hierarchy which is not required anymore, you can use a custom report ZDELE_BUPA_HIERARCHY.
Source code is the following:


REPORT  zdele_bupa_hierarchy.

DATA lv_tree_guid TYPE bu_tree_guid.


PARAMETERS tree TYPE bu_tree_search_term.

SELECT SINGLE tree_guid FROM but_hier_tree INTO lv_tree_guid

  WHERE search_term = tree.

IF sy-subrc = 0.

  IF NOT testrun = 'X'.

    DELETE FROM but_hier_tree WHERE tree_guid = lv_tree_guid.

    DELETE FROM but_hier_tree_d WHERE tree_guid = lv_tree_guid.

    DELETE FROM but_hier_node WHERE tree_guid = lv_tree_guid.

    DELETE FROM but_hier_node_d WHERE tree_guid = lv_tree_guid.

    DELETE FROM but_hier_struct WHERE tree_guid = lv_tree_guid.

    DELETE FROM but_hier_node_bp WHERE tree_guid = lv_tree_guid.


    WRITE: / 'Tree ',tree,' with GUID ',lv_tree_guid, 'was deleted.'.


    WRITE: / 'Tree ',tree,' with GUID ',lv_tree_guid, 'can be deleted.'.




Please create report ZDELE_BUPA_HIERARCHY locally in the CRM server. By default, the program is started in the test mode (TESTRUN flag selected).

Please note, that this report deletes hierarchy from CRM table only, CDB tables are not changed. If condition records refer to hierarchy nodes that were deleted by the report, error messages occur.

It is also strongly not recommended to delete BP Group Hierarchies in Productive environment.