Wednesday, 24 February 2021

Replication of Cost Centers to Employee Central with assignment to additional Generic Objects

Introduction

Program ODTF_REPL_CC is used for replication of Cost Centers from SAP ERP Controlling to Employee Central. It replicates the fixed set of fields: the Long Code prepended with the Controlling Area, the Short Code (aka External Cost Center ID), Start Date, Status, Name, Description, Legal Entity (aka Company Code) and Cost Center Manager.

The program uses IDoc ODTF_CCTR, which is built on basic type ODTF_CCTR01.

In this blog post, we will have a closer look at replication of Cost Centers with assignment to additional Generic Objects.

The reader will learn an alternative to extension of basic IDoc type ODTF_CCTR01.

Details

Let us assume that we want to replicate Cost Centers with assignment to Business Unit and Location. We intend to use these Generic Objects as Field Criteria on Department, Position and Job Information in order to restrict the list of Cost Centers available for selection.

Extension of ODTF_CCTR01 with use of transaction WE30 is not advisable, as the replication would also require a custom CPI package.

Standard CPI package ERPtoSuccessFactorsEmployeeCentralCostCenter processes only the above-mentioned fixed set of fields and cannot be extended.

If we use the standard package, we have to replicate the additional parameters via standard fields, for example the Long Code (which is externalCode) and the Short Code (which is costCenterExternalObjectId).

The Long Code of Cost Center

Let us assume that the code of Cost Center is meaningful and the fifth character represents the Business Unit. For example, Cost Centers ABCD1234567890 and ABCD9876543210 should be associated to Business Unit CORP. We can build this logic into the definition of Business Unit with use of a Custom Composite One-to-many Child Object, for example object cust_FifthCharOfCostCenterCode, as shown below.

SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certification, SAP ABAP Preparation, SAP ABAP Career

Figure 1. An example of the Custom Composite One-to-many Child Object used for evaluation of Business Unit from Cost Center

Now the on-save Business Rule of object Cost Center can use object cust_FifthCharOfCostCenterCode to associate Cost Centers to Business Units, as shown in the code below.

rule() 
{
  if(true) 
  {
    CostCenter.cust_toBusinessUnit = lookup("cust_FifthCharOfCostCenterCode","parent","",
["externalCode","==",substring(text:CostCenter.externalCode,start:"5",length:"1"),"",""]);
  }
}

Code 1. Body of the on-save Business Rule to associate Cost Center to Business Unit

Following the same logic, other fields can be used to assign Cost Centers to Generic Objects.

The Short Code of Cost Center


In standard solution, the Short Code of Cost Center (aka External Cost Center ID) can be used in replication of Employee Data from EC to ERP.

It is used with the following logic: if (1) the Use of External Cost Center ID is enabled in cluster VC_ECPAO_QRY_CFG and (2) field cost-center of HRIS Element jobInfo is replicated directly to field KOSTL of infotype Organizational Assignment (which means that Employees do not inherit Cost Centers from Organizational Management), then the replicated Cost Center is replaced with the value in field costCenterExternalObjectId.

However, as a rule, the Use of External Cost Center ID is disabled, as the Short Code of Cost Center (which is PA0001-KOSTL) is either equal to or can be evaluated from the Long Code (which is externalCode).

Let us assume that field costCenterExternalObjectId is not required for replication of the Short Code of Cost Center. If this is the case, we can utilize field costCenterExternalObjectId (which is 40 characters long) for replication of additional parameters of Cost Center, as shown in the code below.

  METHOD if_odtf_co_repl_idoc_cost_cent~modify_cost_center_extractor.
    LOOP AT cs_cost_centers_idoc-cost_centre ASSIGNING FIELD-SYMBOL(<ls_cost_centre>).
            <ls_cost_centre>-remote_external_object_id = 
            'CODE_OF_LOCATION;CODE_OF_DIVISION'.
    ENDLOOP.
  ENDMETHOD.

Code 2. Replication of additional parameters into field costCenterExternalObjectId

Replication of field costCenterExternalObjectId itself is enabled in SAP CPI in package ERPtoSuccessFactorsEmployeeCentralCostCenter in Externalized Parameter USE_EXTERNAL_COST_CENTER.

When replicated to Employee Central, the parameters can be used to assign Cost Center to other Generic Objects (in our case cust_Location), following the example of Code 1.

No comments:

Post a Comment