Mostly SAP related…
ABAP Code
Vendors in the Sales Document
Aug 10th
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
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
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.
Next to download the partner function implement the following code in method crm_dataexch_r3d_mbdoc_fill.
The text of the code is available here…hope it helps.
<-Updated 05.09.2009 – Corrected some errors in published code->
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.
Passing Custom Fields to Lean Order API
Mar 31st
I recently started working on the ERP Sales Order functionality in the CRM 5.0 WebClient. This is essentially a WebClient view which uses the ERP 6.0 Lean Order API(LORD) to perform all sales order functionality directly in the backend. The benefit is no messy replication of CRM Sales Orders, Config, Pricing and Enhancements.
The problem is that as with all ERP systems customers enhance VA01 over time and the Lean API does not cater for all scenarios, such as additional fields appended to VBAK which must be filled by the user. (UPDATE – See Note 1078575 for restrictions)
The problem is that there seems no(to my knowledge) way to extend the structures of the API to carry these from CRM to ERP in any traditional(i.e. passing parameters) way.
Then this SDN thread prompted me to investigate the innovative implementation of the Lean Order API and I learned something new: Global variables in SAP Programs are externally accessible!
So all you need to do is create a Remote Function module like the one below in ERP.
FUNCTION ZZ_ERPORDER_TRANSFER_FIELD.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(IV_CONTACT_NAME) TYPE ZZCONTACT DEFAULT 'My Abap Test'
*"----------------------------------------------------------------------
field-symbols: <fs_vbak> type vbak.
assign ('(SAPLSLS_LORD)VBAK') to <fs_vbak>.
if sy-subrc = 0.
<fs_vbak>-ZZCONTACT = IV_CONTACT_NAME.
endif.
ENDFUNCTION.The function module above accesses the global VBAK structure in Function Group SLS_LORD and updates it. This is riding rough shod over any concept of variable scope, so please think carefully before implementing this.
Now, all you need is to call the RFC Function Module from CRM. I used an implementation of BADI CRM_IC_ERP_BADI to accomplish this.
method IF_EX_CRM_IC_ERP_BADI~AFTER_CREATION.
call function 'ZZ_ERPORDER_TRANSFER_FIELD'
destination cl_crm_erp_il=>gv_rfc
EXPORTING
IV_CONTACT_NAME = 'Contact Name'.
endmethod.A Code dump
Mar 25th
–Update– The code shown here is not 100% correct and reliable. I will probably fix at some point…
I haven’t posted in a long time, mostly because I have been doing everything except working on a SAP system. So, the first bit of code I have written in a while goes here.
Scenario: Its difficult for BW to create reports according the Category Hierarchy on CRM Service Tickets as maintained in the Category Modeller.
Quick Fix Solution: Append fields for Level 1,2 and 3 to CRMD_CUSTOMER_H using EEWB. Create initial load report and BADI implementation to fill these.
I am not going to explain in much more detail. Hopefully someone finds the code useful.
The code can be found here:Â Category Update Code.
Determining BP Sales Area Data
Sep 26th
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
Sep 4th
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.