In 0CRM_LEAD_H, there are two fields PATH_GUID and TERR_GUID. You may wonder what territory information is filled in them.
During extraction, the lead orders data is firstly retrieved and then the data will be mapped to and filled in data structure of 0CRM_LEAD_H in the following FM CRM_BW_LEAD_H_MAP.
In CRM_BW_LEAD_H_MAP, the partners that has a valid territory will be put in LS_BDOC_MSG – ATTR_TERRITORY.
It calls PERFORM territory_determine to map territory data in LS_BDOC_MSG – ATTR_TERRITORY to path GUID and Terr GUID in 0CRM_LEAD_H.
Which territory will be mapped to that in the 0CRM_LEAD_H is determined by territory_determine.
Its logic is that,
- it will read entries in ATTR_TERRITORY one by one. The entries in ATTR_TERRITORY store both the partner and territory details.
- as soon as the partner has function category 0008, its territory will be immediately taken as the territory of the lead in 0CRM_LEAD_H; It will exit rather than going through the following partners.
- if there is no partner with function category 0008, the territory of the first partner with 0005 (if multiple employees exist) will be considered as that of the lead in 0CRM_LEAD_H.
- if there is no partner with function category 0008 or 0005, the territory of the partner which has the biggest partner function category will be taken as the territory of the lead in 0CRM_LEAD_H.
It does not consider the partner function during territory determination.