I often see systems where the consultant that implemented the solution, assumed that the Customer Number in the R/3 system would be exactly the same as the BP Number in CRM. In most cases this is true(and the system should be configured to map Customer numbers to BP numbers). However, this isn’t always true, especially when using multiple backends.

There are 2 function modules that provide the functionality to map between customer and BP numbers.

The code block below shows the variables that you would typically use when calling these function modules. Note that both the function modules will return the R/3 Account Group as well.

data: lv_partner  type bu_partner_guid,
      lv_customer type crmt_bu_map_customer_number,
      lv_accgroup type crmt_bu_account_group.

Function Module CRM_BUPA_MAP_CUSTOMER_TO_BP will map the CRM BP Number to a Customer Number.

call function 'CRM_BUPA_MAP_BP_TO_CUSTOMER'
  exporting
    iv_partner         = lv_partner
  importing
    ev_customer        = lv_customer
    ev_account_group   = lv_accgroup
  exceptions
    customer_not_found = 1
    others             = 2.

CRM_BUPA_MAP_CUSTOMER_TO_BP will map the R/3 Customer Number to CRM BP Number.

call function 'CRM_BUPA_MAP_CUSTOMER_TO_BP'
  exporting
    iv_customer       = lv_customer
  importing
    ev_partner        = lv_partner
    ev_account_group  = lv_accgroup
  exceptions
    partner_not_found = 1
    others            = 2.