Program ODTF_REPL_CC is used for replication of Cost Centers from SAP ERP Controlling to Employee Central, including the following data: Long Code with the Controlling Area in it, Short Code, Start Date, Status, Name, Description, Legal Entity (aka Company Code) and Cost Center Manager.
In this blog post, we will share details about replication of the Cost Center Manager field.
In SAP ERP Controlling, the Cost Center Manager is stored in table CSKS in field VERAK_USER (User Responsible).
In Employee Central, the Cost Center Manager is stored in object Cost Center in the standard field costCenterManager.
Program ODTF_REPL_CC provides the following four options for replication of Cost Center Manager:
- Read UserID from field VERAK_USER (User Responsible);
- Read UserID from field VERAK (Person Responsible);
- Set UserID in BAdI ODTF_CO_REPL_IDOC_COST_CENTERS;
- Leave UserID empty.
Options 1 and 2 are not used in production, as values of fields VERAK and VERAK_USER cannot be accepted by a User field of Employee Central, which is explained below.
Option 4 is used for replication of Cost Centers without the Cost Center Manager field, which is the most probable scenario in production.
Option 3 with BAdI is the only option that can be used for replication of Cost Center Manager in production, as evaluation of EC UserID requires field VERAK_USER of table CSKS, Infotypes 0000 and 0105, which means that the Infotypes must be synchronized with the Job Information in Employee Central. We will share an example of the BAdI below in the blog post.
The table below summarizes differences between a user field in Employee Central and field VERAK_USER in SAP ERP Controlling.
Table 1. Differences between fields VERAK_USER (User Responsible in ERP) and costCenterManager (Cost Center Manager in EC)
|Field VERAK_USER of table CSKS in ERP||Field costCenterManager of Cost Center in EC|
|The value of the field is the SAP User Name limited to 12 characters, which comes from transaction SU01 in ERP (e.g. CGRANT).||The value of the field is EC UserID, which matches* Personnel Number in SAP ERP HCM (e.g. 00001234).|
|The field does not check the assignment** of the Personnel Number to the SAP User. Moreover, the field can be time-independent.***||The field is time-dependent and checks if the Employee is active in EC on the start date of the Cost Center.|
* For Details about mapping of EC UserID to SAP Personnel Number, see guide “Employee Central Core Hybrid: Handling Employee Identifiers”. ** The Personnel Number is assigned to SAP User in Infotype 0105 Subtype 0001. *** The time-dependency can be checked in transaction OKEH in ERP.
If Option 3 “Set Responsible Manager in BAdI” is selected, then BAdI ODTF_CO_REPL_IDOC_COST_CENTERS evaluates EC UserID. It is saved to the IDoc field ASS_MGR_EE_TEXT and sent to Employee Central as show on the diagram below:
Figure 1 Replication chain of Cost Center Manager from ERP to EC
* Externalized parameter PERSON_RESP_TARGET_FIELD is used for mapping of the IDoc field ASS_MGR_EE_TEXT to field costCenterManager of Cost Center. For details about the mapping, see guide “Replicating Cost Centers from SAP ERP to Employee Central Using SAP Cloud Platform Integration as the Middleware”, § 5.3.5, p. 28.
Let us suppose that field VERAK_USER in table CSKS is time-independent and contains actual information about Cost Center Managers, Infotype 0000 contains actual information about hire and termination dates, and Subtype 0001 of Infotype 0105 contains actual information about assignment of Personnel Numbers to SAP Users, then we can use the following code to evaluate the UserID of the Cost Center Manager.
Code 5. Evaluation of UserID of Cost Center Manager with use of 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.
In the code, value of field VERAK_USER is converted to PERNR and added to the IDoc node “Cost Center Attribute” starting from the date when the Personnel Number become active.
Replication of Cost Center Manager is possible only with use of BAdI and requires synchronized data of Infotypes 0000 and 0105 in SAP ERP and Job Information in Employee Central.
- 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-Example-of-Cost-Centers.pdf (Accessed: 13 January 2021).
- Replicating Cost Centers from SAP ERP to Employee Central Using SAP Cloud Platform Integration as the Middleware. Document Version 2H 2020 – 2020‑10‑16. Available at https://help.sap.com/doc/6e943d18c1f347b88e91b1e605d502e2/2011/en-US/SF_ERP_EC_CC_HCI_en-US.pdf (Accessed: 13 January 2021).
- Employee Central Core Hybrid: Handling Employee Identifiers. Document Version 1.4 – 2020‑05‑31. Available at https://d.dam.sap.com/a/Q3ABoSy/IDP%20-%20Employee%20Central%20Core%20Hybrid%20-%20Employee%20Identifiers%20V1.4.pdf (Accessed: 13 January 2021).