You are on page 1of 29

Reusable Components

CO Integration – CRM and ECC


Prepared by: L&T Infotech

Document Number: CRM-2009-0001


White Paper – CO Integration
Feb 2010
Author: Kaushik Sarkar

Table of contents
1.0 Intended Audience 3
2.0 Executive Summary 3
3.0 CO Integration Settings 3
3.1 Setting up Controlling Integration 3
3.2 Replicating Characteristics for CO Integration 7
3.3 Assign Billing units to Sales & Service Organizations 8
4.0 ECC – Internal Order Settings 9
4.1 Configure Internal Order 9
4.2 Settlement Profile 10
5.0 Profit Center Determination 12
5.1 How Profit Center is determined in CRM Integration 12
5.2 Create a CRM function module ZSRV_PRFCNTR_DET 13
5.3 Activate ECC User Exit PCACRM01 – Tx code SMOD 18
5.4 ECC Profit Center Determination Substitution Rules 25
6.0 Monitoring Internal Order Replication in ECC 25
6.1 Transaction code IAOMG 25

L&T Infotech - Confidential Page 2 of 29


White Paper – CO Integration
Feb 2010
Author: Kaushik Sarkar

1.0 Intended Audience


This White Paper is targeted at SAP CRM functional & Technical Consultants as
well as ECC CO Consultants.

2.0 Executive Summary


This white paper gives a comprehensive detailing of use of Plants in CRM. This
includes:
 Downloading R/3 Plants into CRM
 Plant as CRM Business Partners
 CRM Tables in which Plants are Stored
 Plants in Customer Masters
 Plants in Material Masters
 Plants in Customer Material Inforecords
 Plant Determination in Sales Transaction using standard R/3 Logic i.e.
Customer Material Inforecord, Customer Master of Ship to Party and Material
Master

3.0 CO Integration Settings

3.1 Setting up Controlling Integration


CRM  Transactions  Settings for Service Process  Setup Time sheet and
Controlling Integration

L&T Infotech - Confidential Page 3 of 29


White Paper – CO Integration
Feb 2010
Author: Kaushik Sarkar

L&T Infotech - Confidential Page 4 of 29


White Paper – CO Integration
Feb 2010
Author: Kaushik Sarkar

Controlling Type

 Single Object-Controlling: The performance of controlling at CRM single-object


level using a new internal order that was created automatically. This enables
concurrent costings with planned-/actual costs comparison and results analysis
(WIP, accruals, revenue recognition, and so on).

 Mass-Object Controlling: Controlling at an aggregated level using profitability


segments in the Profitability Analysis component (CO-PA) and/or profit center in
Profit Center Accounting (EC-PCA). The actual costs from the CRM confirmation,
and the revenue from CRM billing are posted directly in CO-PA and/or in Profit
Center Accounting.

 Controlling of Account Assignment Object: Costs and revenues are posted to an


existing account assignment object (SAP delivery: Internal order, sales order item,
and PSP element; enhancement IAOM0001), which is entered under Account
Assignment in the CRM service process.

 cProjects: Single-Object Controlling of PS Project: This enables hierarchical


Controlling, concurrent costings with planned-/actual costs comparison and results
analysis (WIP, accruals, revenue recognition, and so on).

Reference Usage:
For subsequent business transactions, you decide whether the costs and revenue should
be posted to the account assignment object of the reference transaction, or to a new
account assignment object:

Copy: The same account assignment object is used.


Ignore: A new account assignment object is created.
For the controlling type Controlling on Account Assignment Object, the Ignore function
setting is limited because account assignment in subsequent business transactions can no
longer be changed.

To enable you to analyze all planned costs, actual costs, and revenues for all of the
business transactions that belong together logically, choose the setting Copy.
L&T Infotech - Confidential Page 5 of 29
White Paper – CO Integration
Feb 2010
Author: Kaushik Sarkar

Example
CRM Service business scenario; Single-Object Controlling:

The costs and revenue for a CRM service confirmation should be posted to the internal
order of the service order for which the confirmation is made. To do this, you must
select the Copy setting.
If a new internal order should be created for a CRM return, choose the Ignore setting.
You then have separate cost and revenue controlling for the referenced CRM transaction
and for the return.

Controlling Level

Controlling Level
This determines the Controlling level.

For the Controlling type Mass Controlling, the Controlling level is not relevant.

If you choose Item as Controlling level, this can lead to performance problems with large
volumes of data. We therefore recommend you use Transaction as the Controlling level.
Example
For service contracts, Controlling on item level makes sense.

L&T Infotech - Confidential Page 6 of 29


White Paper – CO Integration
Feb 2010
Author: Kaushik Sarkar

3.2 Replicating Characteristics for CO Integration


Once the settings of transaction types and item category and other service
relevant settings are done in CRM they are transferred to ECC.

CRM  Transactions  Settings for Service Process  Integration  Replicate


Service Characteristics Relevant to Controlling

L&T Infotech - Confidential Page 7 of 29


White Paper – CO Integration
Feb 2010
Author: Kaushik Sarkar

3.3 Assign Billing units to Sales & Service Organizations

CRM  Master Data  Organizational Management  Cross-System Assignment of


Organizational Units  Assign Billing Units to Service/Sales Organizations

L&T Infotech - Confidential Page 8 of 29


White Paper – CO Integration
Feb 2010
Author: Kaushik Sarkar

4.0 ECC – Internal Order Settings

4.1 Configure Internal Order


Controlling  Internal Orders  Order Master Data  Define Order Types

L&T Infotech - Confidential Page 9 of 29


White Paper – CO Integration
Feb 2010
Author: Kaushik Sarkar

4.2 Settlement Profile


Controlling  Internal Orders  Actual Postings  Settlement  Maintain
Settlement Profiles

L&T Infotech - Confidential Page 10 of 29


White Paper – CO Integration
Feb 2010
Author: Kaushik Sarkar

L&T Infotech - Confidential Page 11 of 29


White Paper – CO Integration
Feb 2010
Author: Kaushik Sarkar

5.0 Profit Center Determination

5.1 How Profit Center is determined in CRM Integration

In the sales process and in service processing, the profit center is determined during the
replication into the R/3 System and is stored in the translator. The profit center is
determined according to the following sequence:

1. Default profit center from the material/plant combination if material/plant


information transferred from the CRM (not in service processing) and if it is NOT
an intercompany process.

2. Alternative default profit center: If the profit center from step 1 remains initial,
the dummy profit center from PCA Customizing is set.

3. In SAP enhancement PCACRM01, a user exit is available which provides extensive


options to derive the profit center for the CRM integration. You can
 enhance the transfer structure for the profit center substitution (CH_PCASUB) in
existing fields with information which is required in your substitution routine, but
which is not available in the standard system in table PCASUB.
 set the default profit center directly and dispense with the call of a substitution.

This note 396391 contains example source code of how to use the user exit to call
the substitution that is usually defined via 'substitution for the sales order'. Prior
to that, you can use add your own additional information to table CH_PCASUB to
ensure that all required data is available to your substitution correctly. For this
purpose, implement the advance corrections and activate the user exit in
Transaction CMOD (SAP enhancement PCACRM01)

4. Profit center substitution


Within the CRM integration you can create a PCA substitution (Transaction 0KEM)
and assign it to the controlling area (Transaction KECRM_0KEL). Within this
substitution you can derive the profit center from characteristics of structure

L&T Infotech - Confidential Page 12 of 29


White Paper – CO Integration
Feb 2010
Author: Kaushik Sarkar

PCASUB as it is known from the 'substitution for the sales order' in the standard
R/3 System. The reason why a separate substitution has to be created here and
why the rule defined via Transaction 0KEL cannot used is that in the case of calls
from the CRM Server, characteristic values in table PCASUB that are filled by
default within the R/3 System are not filled. If your substitution refers to such
fields, the simple use of your old substitution routine would return incorrect
results. You must therefore create a new substitution routine which can manage
with the small amount of data provided by the CRM Server.

A profit center determined via the substitution overwrites a profit center found in
the user exit.

In intra-company-code processing, these substitution rules make sense if you want


to use a profit center different from the one proposed from the material/supplying
plant combination. The profit center determined by the substitution is used for
the replication of the sales order in the R/3 System and for posting the cost of
sales and the revenues.

In intercompany processing, the substitution rules are necessary to find the selling
profit center. The selling profit center is used for posting the revenues of the
customer billing document. By default, the derivation of the supplying profit
center during the replication of the sales order in the R/3 System occurs from the
material/supplying plant combination. If you want to use another profit center,
you must define and assign the substitution rules in Customizing of Profit Center
Accounting under 'Enterprise Controlling -> Profit Center Accounting ->
Assignments to Profit Centers -> Sales Orders -> Sales Order Substitutions'.

5. `If the profit center is initial after these steps, it is filled via the derivation in CO-
PA. If a found profit center is not valid, the system sets the dummy profit center.

5.2 Create a CRM function module ZSRV_PRFCNTR_DET

L&T Infotech - Confidential Page 13 of 29


White Paper – CO Integration
Feb 2010
Author: Kaushik Sarkar

FUNCTION zsrv_prfcntr_det.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(LV_OBJECT_ID) TYPE CRMT_OBJECT_ID_DB
*" VALUE(LV_PROC_TYPE) TYPE CRMT_PROCESS_TYPE_DB
*" VALUE(LV_SERVICE_ORG) TYPE CRMT_SERVICE_ORG
*" EXPORTING
*" VALUE(DIS_CHANNEL) TYPE VTWEG
*" VALUE(DIVISION) TYPE SPART
*" VALUE(SALES_ORG) TYPE VKORG
*" VALUE(SERVICE_ORG) TYPE VKORG

L&T Infotech - Confidential Page 14 of 29


White Paper – CO Integration
Feb 2010
Author: Kaushik Sarkar

*" VALUE(LV_AC_ASSIGNMENT) TYPE CHAR50


*" VALUE(SALES_DISTRICT) TYPE BZIRK
*"----------------------------------------------------------------------

DATA: lv_guid TYPE crmt_object_guid,


lt_guid TYPE crmt_object_guid_tab,
lt_orgman TYPE crmt_orgman_wrkt,
ls_orgman TYPE crmt_orgman_wrk,
lv_dis_channel TYPE crmt_distribution_channel,
lv_division TYPE crmt_division,
lv_sales_org TYPE crmt_sales_org,
lt_ac_assign TYPE crmt_ac_assign_wrkt,
ls_ac_assign TYPE crmt_ac_assign_wrk,
lt_partner TYPE crmt_partner_external_wrkt,
ls_partner TYPE crmt_partner_external_wrk,
lv_partner_guid TYPE bu_partner_guid,
ls_sales_area TYPE crmt_bus_sales_area,
ls_data TYPE crmt_bus_set0140,
lt_customer_h TYPE crmt_customer_h_wrkt,
ls_customer_h TYPE crmt_customer_h_wrk.

*********************Determine the order Guid based on the transaction number and the
transaction type*********************
SELECT SINGLE guid FROM crmd_orderadm_h INTO lv_guid WHERE object_id =
lv_object_id AND
process_type = lv_proc_type.

APPEND lv_guid TO lt_guid.

***********************Read The Order*************************************


CALL FUNCTION 'CRM_ORDER_READ'
EXPORTING
it_header_guid = lt_guid
IMPORTING
L&T Infotech - Confidential Page 15 of 29
White Paper – CO Integration
Feb 2010
Author: Kaushik Sarkar

et_orgman = lt_orgman
et_partner = lt_partner
et_customer_h = lt_customer_h
et_ac_assign = lt_ac_assign
EXCEPTIONS
document_not_found = 1
error_occurred =2
document_locked =3
no_change_authority = 4
no_display_authority = 5
no_change_allowed = 6
OTHERS = 7.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

****************** Get the sales area details*********************************

READ TABLE lt_orgman INTO ls_orgman WITH KEY ref_guid = lv_guid.


IF sy-subrc = 0.
dis_channel = ls_orgman-dis_channel.
division = ls_orgman-division.
lv_sales_org = ls_orgman-sales_org.

* Get the sales District


READ TABLE lt_partner INTO ls_partner WITH KEY ref_partner_fct = '00000001'.
ls_sales_area-sales_org = lv_sales_org.
ls_sales_area-channel = dis_channel.
ls_sales_area-division = division.

lv_partner_guid = ls_partner-bp_partner_guid.

CALL FUNCTION 'CRM_BUPA_FRG0140_LNK141_READ'


EXPORTING
L&T Infotech - Confidential Page 16 of 29
White Paper – CO Integration
Feb 2010
Author: Kaushik Sarkar

iv_partner_guid = lv_partner_guid
is_sales_area = ls_sales_area
IMPORTING
es_data = ls_data
EXCEPTIONS
no_valid_record_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

sales_district = ls_data-district.

****Convert the Sales organization to R3 org.******

CALL FUNCTION 'CRM_MAPPING_SALES_ORG'


EXPORTING
iv_sales_org = lv_sales_org
CHANGING
cv_vkorg = sales_org
EXCEPTIONS
value_not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.

*** convert the Service organization to R3 org.******

IF lv_service_org IS NOT INITIAL.


CALL FUNCTION 'CRM_MAPPING_SALES_ORG'
L&T Infotech - Confidential Page 17 of 29
White Paper – CO Integration
Feb 2010
Author: Kaushik Sarkar

EXPORTING
iv_sales_org = lv_service_org
CHANGING
cv_vkorg = service_org
EXCEPTIONS
value_not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.

**************Check the account assignment at the header level******************

IF lt_ac_assign IS NOT INITIAL.


READ TABLE lt_ac_assign INTO ls_ac_assign WITH KEY ref_guid = lv_guid.
IF ls_ac_assign-ac_object_type = '03'.
lv_ac_assignment = ls_ac_assign-ac_assignment.
ENDIF.
ENDIF.

IF lv_ac_assignment IS INITIAL.
READ TABLE lt_customer_h INTO ls_customer_h INDEX 1.
lv_ac_assignment = ls_customer_h-zzcustomer_h0401.
ENDIF.

ENDFUNCTION.

5.3 Activate ECC User Exit PCACRM01 – Tx code SMOD

L&T Infotech - Confidential Page 18 of 29


White Paper – CO Integration
Feb 2010
Author: Kaushik Sarkar

L&T Infotech - Confidential Page 19 of 29


White Paper – CO Integration
Feb 2010
Author: Kaushik Sarkar

*********************************************************************************************
*Determine the Profit Center using Substitution rule
*********************************************************************************************
DATA: lv_prctr TYPE cobl-prctr,
ls_chartab TYPE iaom_object_attribute,
lv_vkorg TYPE vkorg,
lv_vtweg TYPE vtweg,
lv_spart TYPE spart,
lv_bzirk TYPE bzirk,
L&T Infotech - Confidential Page 20 of 29
White Paper – CO Integration
Feb 2010
Author: Kaushik Sarkar

lv_bzirk_crm TYPE bzirk,


lv_object_id TYPE char10,
lv_proc_type TYPE char4,
lv_service_org TYPE char14,
lv_ac_assignment TYPE char50,
lv_srv_vkorg TYPE vkorg,
ls_destination TYPE crmrfcpar,
lt_destination TYPE TABLE OF crmrfcpar,
lv_destination TYPE rfcdest,
lv_product TYPE matnr.
.
***********************Get the CRM RFC
destination*******************************************************
CALL FUNCTION 'CRM0_READ_CRMRFCPAR'
EXPORTING
i_consumer = 'CRM'
i_objname = '*'
* I_DOWNLOAD =
* I_RFCDEST =
i_discard_data =''
* I_ACTIVE_CONSUMERS_ONLY = 'X'
TABLES
t_crmrfcpar = lt_destination
EXCEPTIONS
no_entry =1
consumer_not_active =2
OTHERS =3
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

READ TABLE lt_destination INTO ls_destination


WITH KEY consumer = 'CRM'.
lv_destination = ls_destination-rfcdest.
L&T Infotech - Confidential Page 21 of 29
White Paper – CO Integration
Feb 2010
Author: Kaushik Sarkar

************************* Get the Sales Organization************************************************


*1. Read the transaction type
READ TABLE t_chartab INTO ls_chartab WITH KEY data_element =
'CRMT_PROCESS_TYPE_CO '.
lv_proc_type = ls_chartab-value.
CLEAR ls_chartab.

*2. Read the Transaction number


READ TABLE t_chartab INTO ls_chartab WITH KEY data_element = 'CRMT_OBJECT_ID_CO'.
lv_object_id = ls_chartab-value.
CLEAR ls_chartab.

*3. Read the Service Organization


READ TABLE t_chartab INTO ls_chartab WITH KEY data_element =
'CRMT_SERVICE_ORG_CO'.
lv_service_org = ls_chartab-value.
CLEAR ls_chartab.

*4. Get the Sales Organization, Distribution channel, Division, Service Organization &
* the account assignment of the CRM service transaction from CRM

If lv_object_id is not initial or lv_proc_type is not initial or lv_service_org is not initial.

CALL FUNCTION 'ZSRV_PRFCNTR_DET'


DESTINATION lv_destination
EXPORTING
lv_object_id = lv_object_id
lv_proc_type = lv_proc_type
lv_service_org = lv_service_org
IMPORTING
dis_channel = lv_vtweg
division = lv_spart
sales_org = lv_vkorg
service_org = lv_srv_vkorg
lv_ac_assignment = lv_ac_assignment
L&T Infotech - Confidential Page 22 of 29
White Paper – CO Integration
Feb 2010
Author: Kaushik Sarkar

sales_district = lv_bzirk_crm.

ch_pcasub-vkorg = lv_vkorg.

**************************Check the Account


Assignment*******************************************************
IF lv_ac_assignment IS NOT INITIAL.

CALL FUNCTION 'CONVERSION_EXIT_ABPSN_INPUT'


EXPORTING
input = lv_ac_assignment
IMPORTING
output = lv_ac_assignment.
SELECT SINGLE prctr FROM prps INTO ch_prctr WHERE posid = lv_ac_assignment.
ch_call_substitution = ' '.
ENDIF.

**************************Check the Service


Organization****************************************************
*It is recommended that we maintain a Z table entry for the combination of Service Org
and Profit Centre
IF ch_prctr IS INITIAL.
IF lv_service_org = 'O 50001738'.
ch_prctr = 'ESESERV'.
ch_call_substitution = ' '.
ELSEIF lv_service_org = 'O 50002102' OR lv_service_org = 'O 50002108'.
ch_prctr = 'CNASERV'.
ch_call_substitution = ' '.

ENDIF.
ENDIF.

************************** Get the Sales


District*************************************************************
*1. Get the sales district from KUNNR table based on the sales area details

L&T Infotech - Confidential Page 23 of 29


White Paper – CO Integration
Feb 2010
Author: Kaushik Sarkar

IF ch_call_substitution = 'X'.

SELECT SINGLE bzirk FROM knvv INTO lv_bzirk WHERE kunnr = ch_pcasub-kunnr AND
vkorg = lv_vkorg AND
vtweg = lv_vtweg AND
spart = lv_spart.
IF lv_bzirk IS NOT INITIAL.
ch_pcasub-bzirk = lv_bzirk.
ELSE.
ch_pcasub-bzirk = lv_bzirk_crm.
ENDIF.
************************** Get the Item
Division****************************************************************
*
* ch_pcasub-spart = '10'.
IF im_bukrs NE '4000'.
ch_pcasub-spart = '22'.
ENDIF.

************************* Get the Customer Group


5*************************************************************
IF im_bukrs EQ '4000'.
ch_pcasub-kvgr5 = 'Y05'.
ch_prctr = 'CNASERV'.
ENDIF.
ENDIF.

************************** Get the Material Group 1,2,3,4 & 5 of the Product master*****

DATA: ls_mvke TYPE mvke.


CLEAR ls_chartab.
READ TABLE t_chartab INTO ls_chartab WITH KEY data_element =
'COMT_PRODUCT_ID_CO' .
lv_product = ls_chartab-value.

L&T Infotech - Confidential Page 24 of 29


White Paper – CO Integration
Feb 2010
Author: Kaushik Sarkar

SELECT SINGLE * INTO ls_mvke FROM mvke WHERE matnr = lv_product AND
vkorg = lv_vkorg AND
vtweg = lv_vtweg.

ch_pcasub-mvgr1 = ls_mvke-mvgr1.
ch_pcasub-mvgr2 = ls_mvke-mvgr2.
ch_pcasub-mvgr3 = ls_mvke-mvgr3.
ch_pcasub-mvgr4 = ls_mvke-mvgr4.
ch_pcasub-mvgr5 = ls_mvke-mvgr5.

endif.

5.4 ECC Profit Center Determination Substitution Rules

6.0 Monitoring Internal Order Replication in ECC

L&T Infotech - Confidential Page 25 of 29


White Paper – CO Integration
Feb 2010
Author: Kaushik Sarkar

6.1 Transaction code IAOMG

L&T Infotech - Confidential Page 26 of 29


White Paper – CO Integration
Feb 2010
Author: Kaushik Sarkar

L&T Infotech - Confidential Page 27 of 29


White Paper – CO Integration
Feb 2010
Author: Kaushik Sarkar

Note 855906 - BAdI CRM_UPLOAD_CO- changes for CRM Service

Summary

Symptom

The standard behaviour of CRM service documents when transferred to R3 Controlling


does not suit your business scenario. For example, you'd like to create a new internal
order for a follow-up document instead of
posting to the internal order of the originating document.
You'd like to pass a plant or a profit center to CO.

Other terms

CRM_SERVICEORDER_MAP_BDOC2BAPI if_ex_crm_upload_co

Reason and Prerequisites

You want to modify data being transferred from CRM Service documents and R3.

Solution

Please implement the attached coding correction.


Beforehand, please add the following parameter to the method
CHARACTERISTICS_SERVICE_FILL of BAdI CRM_UPLOAD_CO (Transaction SE18):

Parameter CS_SERVCHAR
Type Changing
Tick the boxes 'Pass Value' and 'Optional'.
Reference type BAPISDCOSV.

Save and activate the changes. Make sure that you also regenerate the BAdi. (SE18 -
Utilities(M) - Regeneration)

L&T Infotech - Confidential Page 28 of 29


White Paper – CO Integration
Feb 2010
Author: Kaushik Sarkar

As a result of this correction, the methods CHARACTERISTIC_PLANT_FILL and


CHARACTERISTIC_PROF_CNTR_FILL will no longer be called, as
these fields are now available in the changing structure CS_SERVCHAR of the method
CHARACTERISTICS_SERVICE_FILL. The fields in the structure ES_CUSTOMER_SERVICE are
also available in CS_SERVCHAR, so ES_CUSTOMER_SERVICE also no longer needs to be
filled.
Here is some example coding:

1. To remove the reference to the previous item in a service order


DATA: ls_orderadm_h TYPE bad_orderadm_h_mess.

LOOP AT it_message_ext-orderadm_h INTO ls_orderadm_h.


IF ls_orderadm_h-object_type = 'BUS2000116'.
CLEAR cs_servchar-referenced_object_id.
ENDIF.
ENDLOOP.

2. To enter a plant
cs_servchar-plant = '0001'.
3. TO check if the structure cs_servchar contains header or item data
if cs_servchar-item_type is initial.
* header data
else.
*item data
endif.

L&T Infotech - Confidential Page 29 of 29

You might also like