This blog shall guide you how to retrive the BP from the account hierarchy using some standard FM's when data is passed from ECC.
Requirement : To check if the BP transferred from the ECC, is in the 8th level (Account hierarchy), if yes then capture the BP's on the 6th and 7th level of the hierarchy.
Pre-requisites:
Both ECC, CRM having the Account hierarchy present and connection between ECC and CRM should have been set-up.
Format of the Hierarchy Node: BP/salesorg/division/channel
e.g. 8986932/13002010
So when a customer is created or changed in ECC (based on some factors like industry key, group), along with all the details of the customer, we need to capture the hierarchy and get the BP of the above levels.
Standard FM (CRM): CRM_BUPA_MTCS_TO_MAIN
Create an implicit Z* enhancement: Z _BUPA_MTCS_TO_MAIN.Let take some BP: 555136 at CRM in BPH Tcode, it's on the level 8th and the above level BP No's are 625587 and 762605
These need to be mapped with the BUT000 custom fields L6, L7 Account.
These values need to populate automatically when the data from ECC is created or changed.
So code in the standard FM CRM_BUPA_MTCS_TO_MAIN
You will get the BP no from the ECC:
Now get the path of the BP, if it is in the 8th level or not.
Table: BUT_HIER_NODE
Check in the Hierarchy Node as from ECC it will be in above mentioned format and BP without leading zeroes.
And now give the above hierarchy node guid in
FM: BUHI_GET_PATH_BY_NODE and get the path.
Then take the hierarchy node guid of the level 1 and 2 respectively and use below FM to get the BP's.
Use update statement to update the BUT000.
Hope this helps!!