See how to use ABAP code to add fields to the posting screen in SAP ERP HCM so that the system always provides the latest information about employees. You’ll be able to do postings to fields that are not available by default, such as personnel area, personnel sub area, cost center, employee group, employee subgroup, or any combination of these. In SAP ERP HCM posting transaction code PC00_M99_CIPE, there is no such option available. Using this code means you do not need to filter for location, for example, when you do HR payroll reporting.
Key Concept
Posting payroll results to accounting is one of the subsequent activities performed after a successful payroll run in an SAP system. It usually takes place once each payroll period, as well as after each off-cycle payroll run. After you have exited the payroll run, you need to post the payroll results to the appropriate GL accounts (including cost centers).
Note
The reader of this article should have a basic understanding of how to implement implicit enhancements in an SAP system, and of the SAP ERP HCM system.
In an SAP system, you sometimes need to post payroll results to accounting by personnel area, personnel sub area, cost center, employee group, or employee subgroup. Let’s take an example: Say a few employees are working at two different projects in one month. You want to do the posting at the latest location or project of the employee. This is not possible in a standard posting program.
The standard posting program creates a breakup of posting with two different dates. Suppose the employees are at project 1 from the first of the month to 18th, and are on a second project from the 19th to the 30th. In this case, the system creates two posting records for these dates.
I will explain what to do if you want to post a single record with the latest location without using any third-party tools. Although I use the example of a single employee, in real time there would be more than one employee. The benefit that you get from this type of posting is that the finance department can better manage and check costs.
I’ll start by briefly showing you the SAP standard posting process. Then I’ll show you the code involved in my process and also the details about how to achieve your requirements. You can use this process in any other industry, but the focus will be the posting screen because it is only related to posting in HR. If you are not familiar with the GL posting, see the sidebar, “GL Posting Process” for more detail.
Note
You can download an editable version of the coding examples used in this article here.
Sidebar: The GL Posting Process
The GL posting process does the following:
- Groups together posting-relevant information from payroll results
- Creates summarized documents
- Performs the relevant postings to the appropriate GL accounts and cost centers
Each employee’s payroll result contains different wage types that are relevant to accounting:
- Wage types such as standard salary, bonuses, and overtime represent expenses for the company, which are posted to a corresponding expense account.
- Wage types such as bank transfer, employment tax, or an employee’s contribution to social insurance are the employer’s payables to the employee or the tax office. They are posted as credits to a corresponding payables or financial account.
- In addition, there are wage types, such as the employer’s health insurance contribution, that represent an expense for the enterprise and, at the same time, a payable to the social insurance agency. For this reason, such wage types are posted to two accounts - one debited as an expense, and one credited as a payable.
- Other types of wage types also exist, for example accruals and provisions. These types of wage types are usually posted to two accounts, one debited as an expense and one credited as a provision.
Posting to GL is a two-step process in an SAP system. In the first step you create a posting run using transaction code PC00_M99_CIPE. The posting run is based on the payroll results with a distinctive number, a run-type payroll posting (PP), and the accompanying posting documents. The posting run ensures that payroll results for an employee are only posted once. Processed payroll results for an employee are flagged. If the posting run is successful, it has the status Documents Created. If the posting run is unsuccessful, it gets the status Incorrect Documents. Relevant error messages appear in the Output Log.
A posting run can be executed in three modes:
- A test run without documents (T)
- A simulation run with simulation documents (S)
- A productive run (P)
In a test run, the system checks only whether the balance of expenses and payables is zero, as it should be. In both simulation and productive runs, the system checks all HR and RT tables and the posting information in master data to determine whether they exist and whether they are consistent. When you choose Execute Run for a productive run, the system performs the following steps:
- Selects the employees and their payroll results for the evaluation
- Creates a posting run
- Creates posting documents
After filling in the required criteria at the posting screen and pressing the execute icon, you see the output log, which contains the following information:
- The log shows whether the posting run was successful for all personnel numbers.
- You obtain the list of all employees selected, in red (indicates errors or imbalance) or green (indicates no errors).
- In the Output Log, if it is a successful posting run, the Doc. Creation field in the output log indicates it is Error-Free. If it is unsuccessful, the Doc. Creation field indicates Incorrect.
After the processing, write down the posting run number. If you select the Document Overview button or double-click the Doc. creation line, you can access the document overview screen. This contains a brief summary of the posting document.
After creating the posting document, the second step is to use transaction PCP0 to edit a posting run. You can also release the posting documents from this transaction code if the document contains no errors. After releasing the documents, press the Post Document button to post the documents.
The Usual Process
The standard way to create a posting run is to use transaction code PC00_M99_CIPE. Press Enter to see the main posting screen (Figure 1).

Figure 1
Main posting screen
Select the payroll period. Enter the payroll area and type of document creation. Press Enter to fill the start and end date after filling the Payroll area. This is the case when you select Current Payroll Period from the Period field. If you choose Other as the period, then you need to fill the Payroll Area and Period details as well. Figure 2 shows the posting screen with Current Payroll Period selected. The system has populated the Payroll Area and Period fields automatically.

Figure 2
Main posting screen with sample filled values
Click the execute icon in Figure 2 to get the screen shown in Figure 3, which has the details of the posting. It appears when there is no posting error.

Figure 3
Posting screen without errors
If the posting does contain errors, then the screen shown in Figure 4 appears.

Figure 4
Posting screen with errors
Double-click the Document Overview button and the posting document screen appears (Figure 5).

Figure 5
Posting documents list
Double-click the document number in Figure 5 to get to Figure 6, which displays the details of the posting document.

Figure 6
Posting document details
This is the usual way of posting. In this case, on the main screen you enter the employee numbers manually. Also, there is no option of doing the posting by personnel area, personnel sub area, cost center, employee group, or employee subgroup.
Adding Fields to the Posting Screen
Now I am going to tell you in detail how you can add these fields. You first need to implement an enhancement. Covering the step-by-step procedure to implement an enhancement is beyond the scope of this article, but I provide the details pertinent to this process.
Find the program name of the posting program by following menu path System > Status (Figure 7).

Figure 7
Posting program status screen
Double-click RPCIPE00 to go to Figure 8, which shows the source code of the posting program. You could also copy the program name located in the Program field, run transaction code SE38, paste it, then click the Display button.

Figure 8
Posting program source code
Double-click the line rpcipe0s and the screen in Figure 9 appears. It is the selection screen for the source code of the posting program.

Figure 9
Selection screen of posting program
In this program, you can create enhancements in the same way as you follow the steps for implicit enhancements. After creating and implementing the implicit enhancement, add the code shown in Figures 10 to 17 within it. (I’m assuming that you have basic knowledge about implementing an implicit enhancement.)
The first segment of code is for the data definitions that you use. Copy the code in Figure 10 for creating the data definitions of the posting screen. Paste it in your ABAP Editor where you have implemented the implicit enhancement.

Figure 10
Data definitions for enhancement
Now copy the code in Figure 11 to add additional fields to the posting screen.

Figure 11
Additional fields
Copy the code in Figure 12 to fetch all the data from the database and fill the posting screen employee number field. This data is fetched as per the criteria entered in the newly added fields at the selection screen of the posting screen. This code first fetches all the employee payroll results of the period selected at the selection screen from table HRPY_RGDIR. After that, it gets the latest personnel area details from pc_payresult transaction code table WPBP for every employee. If this personnel area is same as entered on the screen, then it adds this employee to the screen to use for posting. Otherwise the system skips that employee.

Figure 12
Code segment for personnel area
Now copy the code in Figure 13 to fetch all the data from the database personnel sub area and fill the posting screen employee number field. This data is fetched as per the criteria entered in the newly added fields at the selection screen of the posting screen. This code first fetches all the employee payroll results of the period selected at the selection screen from table HRPY_RGDIR. After that, it gets the payroll details of every employee. It gets the latest personnel sub area details from pc_payresult transaction code table WPBP for every employee. If this personnel sub area is the same as entered on the screen, then it adds this employee to the screen for use for posting. Otherwise it skips that employee.

Figure 13
Code segment for personnel sub area
Now copy the code in Figure 14 to fetch all the data from the database cost center and fill the posting screen employee number field. This data is fetched per the criteria entered in the newly added fields on the selection screen of the posting screen. This code first fetches all the employee payroll results of the period selected at the selection screen from table HRPY_RGDIR. After that, it gets the payroll details of every employee. It gets the latest cost center details from pc_payresult transaction code table WPBP for every employee. If this cost center is the same as entered on the screen, then it adds this employee to the screen for use for posting. Otherwise it skips that employee.

Figure 14
Code segment for cost center
Copy the code in Figure 15 to fetch all the data from the database employee group and fill the posting screen employee number field. This data is fetched as per the criteria entered in the newly added fields at the selection screen of the posting screen. This code first fetches all the employee payroll results of the period selected at the selection screen from table HRPY_RGDIR. After that, it gets the payroll details of every employee. It gets the latest cost center details from pc_payresult transaction code table WPBP for every employee. If this employee group is the same as entered on the screen, then it adds this employee to the screen for use for posting. Otherwise it skips that employee.

Figure 15
Code segment for employee group
Copy the code in Figure 16 to fetch all the data from the database employee subgroup and fill the posting screen employee number field. This data is fetched per the criteria entered in the newly added fields on the selection screen of the posting screen. This code first fetches all the employee payroll results of the period selected at the selection screen from table HRPY_RGDIR. After that, it gets the payroll details of every employee. It gets the latest cost center details from pc_payresult transaction code table WPBP for every employee. If this employee subgroup is the same as entered on the screen, then it adds this employee to the screen for use for posting. Otherwise it skips that employee.

Figure 16
Figure 16
Copy the code in Figure 17 to create the header and field labels of the newly created and added fields on the posting screen.

Figure 17
Code for field labels and header
After adding the code from Figures 10 to 17 in your enhancement, activate it. Run posting screen transaction code PC00_M99_CIPE, and the screen looks like Figure 18.

Figure 18
Posting screen after adding new fields
You see that the fields are added at the end of the posting screen and are available on the standard posting screen. Fill in any of the criteria and see the results (Figure 19).

Figure 19
Posting screen with new fields and employee numbers
If you open the Personnel Number field, the screen shown in Figure 20 appears. If you have more than one personnel number, the system automatically fills in all of them in the Personnel Number field.

Figure 20
Posting screen with auto-filled personnel numbers
The rest of the steps for posting are the same as for a normal posting screen.
There is one limitation to this utility: It allows you to select only the last location of an employee. You cannot select previous locations and cannot post or report on multiple locations when an employee is working on more than one project or in more than one location.
Qazi Wasif Ali
Qazi Wasif Ali is an SAP ABAP certified consultant at Descon Engineering Limited in Pakistan. He has more than six years of SAP ABAP experience. He has a degree in computer science and has worked in industries such as packaging, beverages, and chemicals. Previously, he worked at Siemens Pakistan and Abacus Consulting. Qazi has also participated in support projects.
You may contact the author at qaziwasifali786@gmail.com.
If you have comments about this article or publication, or would like to submit an article idea, please contact the editor.