Transferring Cost Center Manager from SAP ERP CO to Employee Central
Introduction
The ODTF_REPL_CC program is used to transfer cost centers from SAP ERP CO to Employee Central, which includes the following data: cost center unique code (i.e. with controlling area code), cost center short code, effective date, status, name, description, a legal entity (so-called company code) and a cost center manager. [1] [2]
In this article, we will describe in detail the possibilities for transferring the “Cost Center Manager” field.
But before we move on to the article, I want to thank Olga Belyaeva for helping with ABAP on the project and checking the code that we share in this article.
Cost Center Manager field
In the SAP ERP Controlling module, the cost center manager is stored in the CSKS table in the VERAK_USER field “Responsible User”, as shown in Figure 1.
In the Employee Central module, the cost center manager is stored in the CostCenter MDF object in the standard costCenterManager field, as shown in Figure 2.
Options for defining cost center managers
As shown in Figure 3, the ODTF_REPL_CC program provides the following four options for evaluating the Cost Center Manager’s UserID:
-
✓ Leave UserID empty
-
✗ Read UserID from VERAK_USER field “Responsible user”
-
✗ Read UserID from VERAK “Owner” field
-
✓ Set UserID using BAdI ODTF_CO_REPL_IDOC_COST_CENTERS
Option 1 is used to transfer cost centers without a manager field, and is the most popular option due to differences between systems.
Options 2 and 3 are never used because neither VERAK_USER nor VERAK is suitable for the UserID field in Employee Central. Table 1 summarizes the differences between the UserID field in the Employee Central module and the VERAK_USER field in the SAP ERP Controlling module.
Table 1. Differences between the VERAK_USER field “Responsible user” in the SAP ERP system and the field costCenterManager “Cost Center Manager” in the Employee Central module
VERAK_USER field of CSKS table in SAP ERP system |
The costCenterManager field of the CostCenter object in the Employee Central module |
The field value is the SAP username with a maximum of 12 characters as in transaction SU01 in SAP ERP (e.g. CGRANT) |
The field value is the UserID which corresponds to the personnel number in SAP HCM (e.g. 00012345)one |
The field does not check the assignment of an SAP user to a personnel number.2 Moreover, the field can be time-independent3 |
The field is time dependent and checks if the employee is active in Employee Central on the start date of the corresponding entry in the CostCenter object |
one For details on mapping the UserID in the Employee Central module to a personnel number in SAP HCM, see the reference guide. Employee Central Core Hybrid: Handling Employee Identifiers. 2 An SAP user is assigned to a personnel number in infotype 0105 in subtype 0001. An SAP user can only be assigned to one personnel number per date, and vice versa. 3 Transaction OKEH in SAP CO module shows which cost center fields are time dependent and which are not
Transfer of Cost Center Managers
Option 4 using the BAdI is the only way to pass the cost center manager defined based on the VERAK_USER field in the CSKS table, the SAP user in infotype 0105 subtype 0001, and finally the employment status in infotype 0000 synchronized between Employee Central and SAP HCM. It is particularly important for this option to deploy the integration to SAP HCM rather than SAP CO, as determining the cost center manager ID requires up-to-date HR activity data.
Figure 4 shows the data required to evaluate the Cost Center Manager’s UserID and then pass the calculated value from the SAP HCM module through SAP Cloud Integration to the Employee Central module. Data transfer is triggered by change pointers ODTF_CCTR when cost centers are created and changed.
* The external parameter PERSON_RESP_TARGET_FIELD is used to map the ASS_MGR_EE_TEXT field in the ODTF_CCTR IDoc in SAP HCM to the costCenterManager field in the CostCenter MDF object in Employee Central. See the reference guide for details on this mapping. Replicating Cost Centers from SAP ERP to Employee Central Using SAP Cloud Platform Integration as the Middleware§ 5.3.5 Configuring the Integration Flow for Cost Center Replication, page 29
Code 1 shows an example of determining the Cost Center Manager UserID using the VERAK_USER field in the CSKS table. This code assumes that the VERAK_USER field is time-independent and contains the current SAP user of the manager, the 0105 subtype infotype contains up-to-date information about the personnel number SAP users, the hire and leave dates in the 0000 infotype are synchronized with Employee Central.
The code uses the VERAK_USER field to get the PERNR and adds the PERNR to the IDoc from the date the personnel number is active.
Code 1: Determine the ID of the Cost Center Manager using the BAdI ODTF_CO_REPL_IDOC_COST_CENTERS
METHOD if_odtf_co_repl_idoc_cost_cent~modify_cost_center_extractor.
DATA:
lt_p0000 TYPE STANDARD TABLE OF p0000,
ls_p0000 TYPE p0000,
lv_pernr TYPE pernr_d,
lv_start_old TYPE datum,
lv_start_new TYPE datum.
LOOP AT cs_cost_centers_idoc-cost_centre ASSIGNING FIELD-SYMBOL(<ls_cost_centre>).
LOOP AT <ls_cost_centre>-cost_centre_attributes
ASSIGNING FIELD-SYMBOL(<ls_cost_centre_attributes>).
CLEAR: lv_pernr, lv_start_new, lv_start_old.
CALL FUNCTION 'ODTF_CC_GET_PERNR_FOR_USER'
EXPORTING
user = <ls_cost_centre_attributes>-ass_mgr_ee_user_account_id
IMPORTING
pernr = <ls_cost_centre_attributes>-ass_mgr_ee_text.
IF sy-subrc <> 0.
CLEAR <ls_cost_centre_attributes>-ass_mgr_ee_text.
ELSE.
WRITE <ls_cost_centre_attributes>-ass_mgr_ee_text TO lv_pernr.
lv_start_old = <ls_cost_centre_attributes>-validity_period_start_date.
READ TABLE lt_p0000 TRANSPORTING NO FIELDS WITH KEY pernr = lv_pernr.
IF sy-subrc = 4.
CALL FUNCTION 'HR_READ_INFOTYPE'
EXPORTING
tclas="A"
pernr = lv_pernr
infty = '0000'
begda="19000101"
endda="99991231"
TABLES
infty_tab = lt_p0000
EXCEPTIONS
infty_not_found = 1
invalid_input = 2
OTHERS = 3.
IF sy-subrc <> 0.
CLEAR <ls_cost_centre_attributes>-ass_mgr_ee_text.
ENDIF.
ENDIF.
LOOP AT lt_p0000 TRANSPORTING NO FIELDS
WHERE pernr = lv_pernr AND stat2 = '3'
AND begda <= lv_start_old AND endda >= lv_start_old.
ENDLOOP.
IF sy-subrc <> 0.
CLEAR <ls_cost_centre_attributes>-ass_mgr_ee_text.
SORT lt_p0000 DESCENDING BY pernr begda.
LOOP AT lt_p0000 INTO ls_p0000
WHERE pernr = lv_pernr AND stat2 = '3'
AND begda >= lv_start_old
AND endda <= <ls_cost_centre_attributes>-validity_period_end_date.
lv_start_new = ls_p0000-begda.
ENDLOOP.
IF sy-subrc = 0.
<ls_cost_centre_attributes>-validity_period_start_date = lv_start_new.
APPEND <ls_cost_centre_attributes> TO <ls_cost_centre>-cost_centre_attributes.
<ls_cost_centre_attributes>-validity_period_start_date = lv_start_old.
<ls_cost_centre_attributes>-validity_period_end_date = lv_start_new - 1.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
ENDLOOP.
ENDMETHOD.
The weak point in this integration is the ability to assign a new personnel number to an existing SAP user without corresponding changes to the cost center, which in turn does not create a change pointer ODTF_CCTR and therefore does not trigger the transfer of a new existing manager ID.
You can solve this problem by storing the personnel number in the cost center. So updating the personnel number associated with the SAP user in the VERAK_USER field will create a change pointer with message type ODTF_CCTR.
Figure 5 shows how a client program that updates personnel numbers in the VERAK field is integrated into delta replication. For more information about change pointers with message type ODTF_CCTR, see the reference manual Replicating Cost Centers from SAP ERP to Employee Central Using SAP Cloud Platform Integration as the Middleware§ 7.4 Configuring and Running Delta Replication, page 48.
findings
The automatic transfer of cost center managers is only possible using BAdIs, only if infotype 0000 is synchronized with Employee Central, and only if the payroll numbers of cost center managers are stored in the cost centers themselves in SAP HCM.
Bibliography
-
Latyshenko V. V. The Core Hybrid integration model on the example of Cost Centers [Электронный ресурс] // SAPinsider. 2020 URL: https://www.sapinsideronline.com/wp-content/uploads/2020/12/The-Core-Hybrid-Integration-Model-on-the-Example-of-Cost-Centers.pdf (Date of access: 04/10/2022).
-
Replicating Cost Centers from SAP ERP to Employee Central Using SAP Cloud Integration as the Middleware. Document Version: 1H 2022 – 2022-04-07 [Электронный ресурс]. URL: https://help.sap.com/doc/6e943d18c1f347b88e91b1e605d502e2/latest/en-US/SF_ERP_EC_CC_HCI_en-US.pdf (Date of access: 04/10/2022).
-
Employee Central Core Hybrid: Handling Employee Identifiers. Document Version: 1.5 [Электронный ресурс]. URL: https://d.dam.sap.com/a/Q3ABoSy/IDP Employee Central Core Hybrid – Employee Identifiers V1.6.pdf (Date of access: 04/10/2022).
[1] Cost centers in the Russian translation of SAP ERP are called cost centers, abbreviated as cost centers
[2] If you have the choice to transfer cost centers from either SAP CO or SAP HCM, then choosing SAP HCM is preferable to ensure that the list of cost centers is the same in SAP HCM and Employee Central.