Business Partner

Determining BP Sales Area Data

Here is some code that will help you to determine the Sales Areas assigned to a CRM Business Partner and also the sales area details maintained for the BP.

The variables you will need are provided below:

data: lv_partner_guid type  bu_partner_guid,
      lt_sales_areas  type  crmt_bus_sales_area_t,
      ls_data         type  crmt_bus_set0030,
      lv_owner        type  crmt_bu_set_owner,
      lt_return       type  bus_bapi-return_table,
      lv_error        type  bus_bapi-error.
field-symbols: <fs_sales_area> type  crmt_bus_sales_area.

Below is the code which allows you to retrieve the billing data tab(price group, currency, customer group, etc) .

    call function 'CRM_BUPA_FRG0030_GET_LIST'
      exporting
        iv_partner_guid = lv_partner_guid
      importing
        et_sales_areas  = lt_sales_areas.

    loop at lt_sales_areas assigning <fs_sales_area>.
      call function 'CRM_BUPA_FRG0030_GET_DETAIL'
        exporting
          iv_partner_guid = lv_partner_guid
          is_sales_area   = <fs_sales_area>;
        importing
          es_data         = ls_data
          ev_owner        = lv_owner
          et_return       = lt_return
          ev_error        = lv_error.
    endloop.

The export parameter ev_owner will contain an X if CRM is the owner of the set.

The function module CRM_BUPA_FRG0010* allows you to read the Sales Data tab and CRM_BUPA_FRG0020* allows you to read the Shipping Data tab on the BP.

Customer and BP Numbers

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.