# Employee Master Data and Active Directory Comparison and Update

> An interface program that compares hires, leavers and organizational changes in SAP HCM with the accounts in the corporate directory (Active Directory) and updates the differences. Job title, department, manager and cost centre are pushed to the directory; leavers have their directory account and SAP user locked, and new hires get users in SAP and connected systems. Every step is tracked with a log and an error file.

- Type: Program, Custom development, Interface
- Module: HCM
- Estimated effort: L (12–18 working days)
- Last updated: 2026-11-18
- URL: https://nekuhub.com/en/programs/employee-master-data-active-directory-comparison-and-update/


## Why is the standard not enough?

SU01 and SU10 maintain users one by one or in bulk, and PA30 stores the user name and e-mail in infotype 0105; but there is no ready comparison and update tool between SAP HCM and the directory. This normally requires a separate identity management product. For companies without one, the program treats HR master data as the single source and aligns the directory and SAP users with it.

### Closest standard alternatives

- SU10: Changes or locks users in bulk; does not compare them with HR master data.
- PA30: User and e-mail are entered manually in infotype 0105; there is no directory synchronization.

## Tables used

| Table | Role | Access | Join | System |
|---|---|---|---|---|
| PA0000 | Actions and employment status (driving table) | Read | - | ECC + S/4 |
| PA0001 | Org unit, position and cost centre | Read | PA0001-PERNR = PA0000-PERNR | ECC + S/4 |
| PA0002 | First and last name | Read | PA0002-PERNR = PA0000-PERNR | ECC + S/4 |
| PA0105 | SAP user name and e-mail (communication) | Read / write | PA0105-PERNR = PA0000-PERNR | ECC + S/4 |
| HRP1000 | Org unit and position names | Read | HRP1000-OBJID = PA0001-ORGEH / PA0001-PLANS | ECC + S/4 |
| HRP1001 | Manager relationship (A012) | Read | HRP1001-OBJID = PA0001-ORGEH AND HRP1001-SUBTY = 'A012' | ECC + S/4 |
| USR02 | SAP user: lock and validity | Read / write | USR02-BNAME = PA0105-USRID | ECC + S/4 |

## BAPIs and functions used

- RH_GET_LEADER: Finds the manager of an org unit
- BAPI_USER_LOCK: Locks the SAP user of a leaver
- BAPI_USER_CHANGE: Updates the user's validity date and address data
- BAPI_USER_CREATE1: Creates SAP users for new hires
- HR_INFOTYPE_OPERATION: Writes the user name and e-mail from the directory to infotype 0105

## Selection screen parameters

| Parameter | Description | Type | Reference field | Required |
|---|---|---|---|---|
| S_BUKRS | Company code | Range / multiple | PA0001-BUKRS | No |
| S_PERNR | Personnel number | Range / multiple | PA0000-PERNR | No |
| P_MODE | Run: delta / full comparison | Radio button | - | Yes |
| P_LOCK | Lock SAP users of leavers | Checkbox | - | No |
| P_CREATE | Create users for new hires | Checkbox | - | No |
| P_TEST | Test run | Checkbox | - | No |

## Result list columns

| Column | Source |
|---|---|
| Personnel no. | PA0000-PERNR |
| First name | PA0002-VORNA |
| Last name | PA0002-NACHN |
| SAP user | PA0105-USRID |
| Org unit | HRP1000-STEXT |
| Directory account | Calculated: Logon name returned by the directory |
| Difference | Calculated: Attributes that differ (title, department, manager, status) |
| Action | Calculated: Create, update, disable or none |
| Result | Calculated: Success, error or test |

## How does the program work?

1. By change date (since the last run), PA0000 (action and employment status STAT2), PA0001 (org unit, position, cost centre), PA0002 (first and last name) and PA0105 (subtype 0001 SAP user, 0010 e-mail) are read.
2. Org unit and position names come from HRP1000; the manager is found with RH_GET_LEADER (HRP1001 relationship A012 'manages').
3. The account list from the directory is taken through middleware via an LDAP query or the directory API; the matching key is the personnel number (employee ID attribute) or the e-mail in PA0105.
4. For every record the comparison sets an action: new account, attribute update (title, department, manager, cost centre), disable, or no action.
5. For leavers (STAT2 = 0) the SAP user is locked with BAPI_USER_LOCK and its validity end is set to the leaving date with BAPI_USER_CHANGE; the directory account is disabled through the middleware.
6. For new hires, an SAP user is created with BAPI_USER_CREATE1 according to the position-to-role mapping in a rule table; the user name and e-mail from the directory are written back to PA0105 with HR_INFOTYPE_OPERATION.
7. A test run only shows the difference list. In a live run every action is logged, and failed ones go to an error file that can be reprocessed.

## Authorization objects

- P_ORGIN: Authorization to read employee data by personnel area, employee group and infotype
- S_USER_GRP: Authorization to create, change and lock users by user group

## Frequently asked questions

### Is it needed when an identity management product is in place?

No. If an identity management product exists, it runs this flow. The program is for companies without such a product or that only want to connect SAP HCM with the directory.

### How does it connect to the directory?

The connection depends on the company's middleware: a direct LDAP query or an integration service calling the directory API. The SAP side stays the same; only the connection layer is adapted during installation.

### Does it work on S/4HANA?

Yes. The user BAPIs and HCM infotypes are the same on S/4HANA. Because employees are also business partners there, business partner synchronization is left to the standard employee-to-business-partner sync.

---
Let us build this program for your system: https://nekuhub.com/en/request-a-quote/?report=hcm-employee-active-directory-sync
