BREAK dungbv7.
1. Understanding business requirements
In the SAP HCM system, Cost Center is an object that used for collect employee salary expenses. Different employees are assigned to different Cost Centers based on their Positions, Organizational Units, Working Locations, etc.
Cost Centers are also linked with Profit Centers and Fund Centers to represent the source of profit and the budget used for this cost.
Normally, all the salary components of the employee will be posted into the master Cost Center which is the one display in IT0001 Organizational Assignment. This Cost Center are derived from the Position or Org. Unit of the employee.
In some cases, there are some employees who are paid extra salary components to perform some specific tasks, for example to run a side project of the company.
In terms of cost accounting, the company wants to separate this expense with the monthly salary of the employee. This leads to the need of assign this extra salary component into a new Cost Center rather than let it posted to the Master Cost Center above.
So when creating records IT0014 IT0015 IT2010 or IT0267, the SAP HCM user can click on the Cost Assignment button then fill in the new Cost Center specifically for the pay component:
In this blog post, I will guide you how to create this Cost Assignment record using the famous FM HR_INFOTYPE_OPERATION.
2. Understanding system design
In the SAP HCM system, when an infotype record has a external reference for cost assignment, you will see a flag X in REFEX field:
The information about Cost Center/Company Code/WBS code/... will be present in the ASSHR and ASSOB tables. You can query the data from ASSHR and ASSOB at the same time with the view ASSOB_HR:
Normally in SAP HCM system when we need to manipulate infotype data through custom program, we have 2 options:
First one is to create a BDC program (record the operations performed on the screen just like the LSMW tool)
Second is to use standard utilities such as Class methods, Interfaces, Function Module, BAPI,...
There is well-known function module related to manipulating PA infotype data, which is HR_INFOTYPE_OPERATION.
Unfortunately, this FM does not support the creation of Cost Assignment records.
Note: Please don't get confused with the Secondary Record and Cost Assignment Record.
Secondary record is a dependent infotype record that is created at the same time with the primary infotype record.
For example, in SAP HCM Singapore, dependent informations are stored in 2 infotypes: 0021 (Family Members/Dependents) - primary infotype and 0412 (SG Family Members) - secondary infotype.
Both primary and secondary infotype have the structure of PNNNN (P0000 to P9999) while Cost Assignment Record has the structure PREF:
Without further ado, here is how to create Cost Center Assignment with HR_INFOTYPE_OPERATION
#1 Clone HR_INFOTYPE_OPERATION into ZHR_INFOTYPE_OPERATION and create a new input parameter named REFERENCE_RECORD:
#2 Add this piece of code right before the line of
CALL FUNCTION 'HR_MAINTAIN_MASTERDATA'
Now let's test this new function module with a Cost Center assignment record:
The result is exactly what we expected :D
Ok I guess this is the end. Hopefully through this post you can obtain something that useful for yourself, thanks for reading and see you again soon.
May the best solution be with you!