OHEM table in SAP Business One (Employees (employee master data))
OHEM is the SAP Business One employee master data table: one row per employee with name, job title, department, branch, manager, start and termination dates, and links to a user (userId) and a sales employee (salesPrson). Documents store the document owner in OwnerCode, which joins to OHEM.empID.
OHEM key fields
| Field | What it holds |
|---|---|
empID | Employee number, the key. OINV.OwnerCode and OCRD.OwnerCode point to it. |
firstName / middleName / lastName | Employee name. |
jobTitle | Job title. |
position | Position (OHPS). |
dept | Department (OUDP). |
branch | Branch (OUBR). |
manager | Manager, another OHEM.empID. |
userId | User of the employee. Joins to OUSR.USERID. |
salesPrson | Sales employee. Joins to OSLP.SlpCode. |
startDate / termDate | Start and termination dates. |
Active | Y = active, N = inactive. |
CostCenter | Cost center (OPRC). |
How OHEM relates to other tables
OHEM is master data. OHEM.manager points to another row of OHEM, OHEM.userId to OUSR and OHEM.salesPrson to OSLP. Document headers store the document owner in OwnerCode and business partners the owner in OCRD.OwnerCode, both pointing to OHEM.empID. OHEM also holds personal data, so select only the columns a report needs.
Common joins
OHEM T0 LEFT JOIN OHEM T1 ON T1.empID = T0.manager (manager of the employee)OHEM T0 LEFT JOIN OUSR T2 ON T2.USERID = T0.userId (user of the employee)OHEM T0 LEFT JOIN OSLP T3 ON T3.SlpCode = T0.salesPrson (sales employee)OINV T4 INNER JOIN OHEM T0 ON T0.empID = T4.OwnerCode (owner of the invoice)
When you use the OHEM table
Use OHEM for an org chart (employee and manager), to show the document owner on reports, to check which employees have a user or a sales employee linked, and to list active employees per department.
Example query: active employees with manager, user and sales employee
SQL Server
SELECT T0.empID, T0.firstName, T0.lastName, T0.jobTitle, T1.firstName + ' ' + T1.lastName AS Manager, T2.USER_CODE, T3.SlpName FROM OHEM T0 LEFT JOIN OHEM T1 ON T1.empID = T0.manager LEFT JOIN OUSR T2 ON T2.USERID = T0.userId LEFT JOIN OSLP T3 ON T3.SlpCode = T0.salesPrson WHERE T0.Active = 'Y' ORDER BY T0.lastName, T0.firstName
SAP HANA (column names in double quotes)
SELECT T0."empID", T0."firstName", T0."lastName", T0."jobTitle", T1."firstName" || ' ' || T1."lastName" AS "Manager", T2."USER_CODE", T3."SlpName" FROM OHEM T0 LEFT JOIN OHEM T1 ON T1."empID" = T0."manager" LEFT JOIN OUSR T2 ON T2."USERID" = T0."userId" LEFT JOIN OSLP T3 ON T3."SlpCode" = T0."salesPrson" WHERE T0."Active" = 'Y' ORDER BY T0."lastName", T0."firstName"
Paste either version in Tools → Queries → Query Generator. Need the other dialect for your own query? Use the SQL to HANA converter.
Common pitfall: Confusing the document owner with the creating user
OwnerCode on a document is an employee (OHEM.empID), while UserSign is the user who created it (OUSR.USERID). They are different numbers in different tables. Join OwnerCode to OHEM and UserSign to OUSR, and keep salary, ID and passport columns out of general reports. See OUSR table (users).
Ready-made queries that use OHEM
- Sales by sales employee: Invoice count and net sales per sales employee for a period.
Questions about the OHEM table
How do I link an employee to an SAP Business One user?
OHEM.userId joins to OUSR.USERID.
Where is the document owner stored?
In OwnerCode on the document header, which joins to OHEM.empID.
How do I find the manager of an employee?
OHEM.manager holds the empID of the manager; join OHEM to itself.
Related tables
OUSR (Users) · OSLP (Sales Employees) · OINV (A/R Invoice (header)) · search all SAP Business One tables
Sources: SAP Business One documentation and SDK (DI API database tables reference), SAP Help Portal.
Ready to get started?
Tell us what you need. You get a clear technical answer, a fixed scope and a price, usually within 24 hours.
