Human Capital Management Blogs by Members
Gain valuable knowledge and tips on SAP SuccessFactors HCM suite and human capital management market from member blog posts. Share your insights with a post of your own.
cancel
Showing results for 
Search instead for 
Did you mean: 
Latyshenko2
Active Participant
This article came into being because the help guide Replicating Cost Centers from SAP ERP to Employee Central Using SAP Cloud Integration as the Middlew... mentions in passing that the transfer of the Cost Center Manager requires a valid UserID but does not explain how to get the valid value. On one of our projects, we have implemented a universal solution for the replication of the Cost Center Managers, which now we are going to share with the reader.

Introduction


Program ODTF_REPL_CC is used for the replication of Cost Centers from SAP ERP Controlling to Employee Central, which includes the following data: the unique code of Cost Center (i.e. with the code of the Controlling Area), the short code of Cost Center, Start Date, Status, Name, Description, Legal Entity (aka Company Code) and Cost Center Manager.[1]

In this article, we will describe in details the options for the replication of field ‘Cost Center Manager.’

And before we delve into the details, I would like to thank Olga Belyaeva for helping with ABAP on the project and reviewing the programming code that we share in this article.

Field ‘Cost Center Manager’


In SAP ERP Controlling, the Cost Center Manager is stored in table CSKS in field VERAK_USER ‘User Responsible,’ as shown in Figure 1.


Figure 1. Creation of a Cost Center using transaction KS01 in SAP ERP Controlling


In Employee Central, the Cost Center Manager is stored in MDF-object CostCenter in the standard field costCenterManager, as shown in Figure 2.


Figure 2. Creation of Cost Center using tool ‘Manage Data’ in Employee Central



Options for the evaluation of Cost Center Managers


As shown in Figure 3, program ODTF_REPL_CC provides the following four options for the evaluation of UserID of Cost Center Manager:

  1. Leave UserID empty

  2. Read UserID from field VERAK_USER ‘User Responsible’

  3. Read UserID from field VERAK ‘Person Responsible’

  4. Set UserID in BAdI ODTF_CO_REPL_IDOC_COST_CENTERS



Figure 3. The options for the evaluation of UserID of Cost Center Manager


Option 1 is used for the replication of Cost Centers without the field for the Manager, and it is the most popular option due to the differences between the systems.

Options 2 and 3 are never used because neither VERAK_USER nor, moreover, VERAK is valid for the UserID field in Employee Central. Table 1 summarizes the differences between field UserID in Employee Central and field VERAK_USER in SAP ERP Controlling.

Table 1. The differences between field VERAK_USER ‘User Responsible’ in system SAP ERP and field costCenterManager ‘Cost Center Manager’ in module Employee Central















Field VERAK_USER of table CSKS in system SAP ERP Field costCenterManager of object CostCenter in module Employee Central
The value of the field is the SAP User Name with length not more than 12 characters like in transaction SU01 in SAP ERP (e.g. CGRANT) The value of the field is the UserID, which matches Personnel Number in SAP HCM (e.g. 00012345)1
The field does not check the assignment of the SAP User to the Personnel Number.2 Moreover, the field can be time-independent3 The field depends on time and checks if the employee is active in Employee Central on the start date of the respective record of the CostCenter object

1 For details about the mapping of UserID in Employee Central to Personnel Number in SAP HCM, see the help guide Employee Central Core Hybrid: Handling Employee Identifiers. 2 The SAP User is assigned to the Personnel Number in Infotype 0105 Subtype 0001. On one date, one SAP User can be assigned only to one Personnel Number, and vice versa. 3 Transaction OKEH in SAP ERP Controlling shows which fields of Cost Center depend on time and which do not

Replication of Cost Center Managers


Option 4 that uses the BAdI is the only way to transfer the Cost Center Manager evaluated based on field VERAK_USER in table CSKS, SAP User in intotype 0105 subtype 0001 and finally the Employment Status in infotype 0000 synchronized between Employee Central and SAP HCM. It is especially important for this option to deploy the integration in SAP HCM rather than in SAP CO because the evaluation of UserID of Cost Center Manager requires the actual data of the Personnel Actions.

Figure 4 demonstrates the data required for the evaluation of UserID of Cost Center Manager and the following transfer of the evaluated value from SAP HCM via SAP Cloud Integration to Employee Central. The transfer of data is triggered by the ODTF_CCTR change pointers upon the creation and the update of Cost Centers.


Figure 4. The sequence of evaluation and transfer of Cost Center Manager from SAP HCM to Employee Central. * The externalized parameter PERSON_RESP_TARGET_FIELD is used for mapping of field AS S_MGR_EE_TEXT in IDoc ODTF_CCTR in SAP HCM to field costCenterManager of object CostCenter in Employee Central. For details about the mapping, see the help guide Replicating Cost Centers from SAP ERP to Employee Central Using SAP Cloud Integration as the Middlew..., § 5.3.5 Configuring the Integration Flow for Cost Center Replication, p. 29


Programming Code 1 demonstrates an example of the evaluation of UserID of Cost Center Manager with the use of field VERAK_USER in table CSKS. The code assumes that field VERAK_USER does not depend on time and contains the actual SAP User of the manager, infotype 0105 subtype 0001 contains the actual information about SAP Users of Personnel Numbers, the hire and the termination dates in infotype 0000 are synchronized with Employee Central.

The code uses field VERAK_USER to get PERNR and adds PERNR to the IDoc starting from the date when the Personnel Number is active.

Programming Code 1. The evaluation of UserID of Cost Center Manager using 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>-as s_mgr_ee_user_account_id "delete the space
IMPORTING
pernr = <ls_cost_centre_attributes>-as s_mgr_ee_text.
IF sy-subrc <> 0.
CLEAR <ls_cost_centre_attributes>-as s_mgr_ee_text.
ELSE.
WRITE <ls_cost_centre_attributes>-as s_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>-as s_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>-as s_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 spot in the integration is the possibility to assign a new Personnel Number to the existing SAP User without the respective changes in the Cost Center, which, in turn, does not create the ODTF_CCTR change pointer and, thus, does not trigger the transfer of the new UserID of the existing manager.

This issue can be resolved by storing the Personnel Number in the Cost Center. Thus, the update of Personnel Number assigned to the SAP User of field VERAK_USER creates the change pointer with the ODTF_CCTR message type.

Figure 5 demonstrates how the custom program updating the Personnel Numbers in field VERAK is built into the delta replication. For more details about the change pointer with the ODTF_CCTR message type, see the help guide Replicating Cost Centers from SAP ERP to Employee Central Using SAP Cloud Integration as the Middlew..., § 7.4 Configuring and Running Delta Replication, p. 48.


Figure 5. The diagram of the integration flow for the delta replication of Cost Center



Conclusion


The automatic replication of Cost Center Managers is possible only with the use of BAdI, only if infotype 0000 is synchronized with Employee Central, and only if the Personnel Numbers of the Cost Center Mangers are stored in the Cost Centers themselves in SAP HCM.

Reference list



  1. Latyshenko, V. V., 2020. The Core Hybrid integration model on the example of Cost Centers. SAPinsider, [online]. Available at https://www.sapinsideronline.com/wp-content/uploads/2020/12/The-Core-Hybrid-Integration-Model-on-the... (Accessed: 10 April 2022).

  2. Replicating Cost Centers from SAP ERP to Employee Central Using SAP Cloud Integration as the Middleware. Document Version: 1H 2022 – 2022-04-07. Available at https://help.sap.com/doc/6e943d18c1f347b88e91b1e605d502e2/latest/en-US/SF_ERP_EC_CC_HCI_en-US.pdf (Accessed: 10 April 2022).

  3. Employee Central Core Hybrid: Handling Employee Identifiers. Document Version: 1.5. Available at https://d.dam.sap.com/a/Q3ABoSy/IDP%20-%20Employee%20Central%20Core%20Hybrid%20-%20Employee%20Identi... (Accessed: 10 April 2022).





[1] If there is a choice of transferring the Cost Centers either from SAP ERP Controlling or from SAP HCM, then the latter is more preferable in order to ensure the same list of Cost Centers in SAP HCM and Employee Central


Russia

Author: Vladimir Latyshenko
Labels in this area