I recently had a requirement were a vendor had to be replicated as partner function from a CRM Sales Order to an SD Sales Order.

At first I thought there wasn’t going to be any problem as it seems this is fully supported by customizing. The mapping between partner functions in ERP and CRM can be maintained respectively as shown below. In my case I wanted to replicate a Carrier(Partner function SP in German…it displays as CR in English). Also, note that partner function

IMG: Customer Relationship Management -> Basic Functions -> Partner Processing -> Data Transfer -> Distribution of Partner Functions from SAP ECC into CRM

erp2crm

The above setting will cause partner function SP to be remapped to my new partner function ZR in CRM.

Next you must maintain the mapping from CRM, back to ERP. This table you must always maintain even if you only want to download partner functions as the download from ERP reads the upload table as well(…makes sense right?).

IMG: Customer Relationship Management -> Basic Functions -> Partner Processing -> Data Transfer -> Distribution of Partner Functions from CRM into SAP ECC

crm2erp

What is important to note is the last column which indicates that this is a vendor mapping, and you would think the system would take that into account when uploading/downloading the Sales Order.

Unfortunately this didn’t work, which then prompted a Notes Search which produced Note 1303575. The gist of the note is:

Symptom: Partners of the type “LI” are not supported in the CRM sales document.

Solution: There is none.

Now, lets recap a couple of things:

1. Vendors can be downloaded to CRM using Middleware as described in Note 883162.

2. BP Relationships for Vendors can be downloaded as per Note 975195.

3. Customizing indicates the partner function is a vendor, so why not just map to a vendor instead of a customer?

Lets just say I will reserve my opinion of on the above note.

Anyway the fix is relatively simple. You create an implementation of CRM_DATAEXCHG_BADI in SE19.

To upload the Vendor Partner Function to ERP implement the code below method crm_dataexch_after_bapi_fill.

crm-to-erp

Next to download the partner function implement the following code in method crm_dataexch_r3d_mbdoc_fill.

erp-to-crm

The text of the code is available here…hope it helps.

<-Updated 05.09.2009 – Corrected some errors in published code->

method if_ex_crm_dataexchg_badi~crm_dataexch_after_bapi_fill.

field-symbols: <fs_parnr3> type bapiparnr3.

data: lv_partner_guid      type bu_partner_guid,
lv_vendno            type crmt_bu_map_vendor_number.
**  make sure plant info is not return to ERP as a Partner
delete ct_bapiparnr3 where partn_role = ‘ZP’.

read table ct_bapiparnr3 assigning <fs_parnr3>
with key partn_role = ‘SP’.
if sy-subrc = 0.
lv_partner_guid  = <fs_parnr3>-partn_guid.
select single vendor_no into lv_vendno
from crmm_but_vendno
where partner_guid = lv_partner_guid.
if sy-subrc = 0.
<fs_parnr3>-partn_numb = lv_vendno.
clear <fs_parnr3>-partn_guid.
endif.
endif.

endmethod.