Documents waiting for approval
Approval requests still pending, with the document type, originator and age in days.
Tool
SELECT T0.WddCode, T0.ObjType, T0.DocEntry, T1.U_NAME AS Originator, T0.CreateDate, DATEDIFF(day, T0.CreateDate, GETDATE()) AS DaysWaiting FROM OWDD T0 INNER JOIN OUSR T1 ON T0.OwnerID = T1.USERID WHERE T0.Status = 'W' ORDER BY DaysWaiting DESC
SELECT T0."WddCode", T0."ObjType", T0."DocEntry", T1."U_NAME" AS "Originator", T0."CreateDate", DAYS_BETWEEN(T0."CreateDate", CURRENT_TIMESTAMP) AS "DaysWaiting" FROM OWDD T0 INNER JOIN OUSR T1 ON T0."OwnerID" = T1."USERID" WHERE T0."Status" = 'W' ORDER BY "DaysWaiting" DESC
What this query answers
When a salesperson complains that an order is stuck, or a purchase request has not moved for days, the operations manager needs every request still waiting for approval. Sorting by age shows which approvers are holding things up.
Sample output
Illustrative demo values. Your columns are the same; the numbers come from your company.
| WddCode | ObjType | DocEntry | Originator | CreateDate | DaysWaiting |
|---|---|---|---|---|---|
| 118 | 22 | 512 | Maria Lopez | 2026-10-15 | 9 |
| 124 | 17 | 4120 | Daniel Ortiz | 2026-10-20 | 4 |
| 127 | 1470000113 | 88 | Omar Saleh | 2026-10-23 | 1 |
SQL Server vs SAP HANA
DATEDIFF(day, T0.CreateDate, GETDATE()) becomes DAYS_BETWEEN(T0."CreateDate", CURRENT_TIMESTAMP). The status filter 'W' is case-sensitive in HANA, so it must stay upper case.
Common errors and fixes
- The DocEntry does not open the right document: A document waiting for approval is still a draft. Join OWDD.DraftEntry to ODRF.DocEntry to get the draft number, customer and total.
- ObjType shows only numbers: ObjType is the document type: 17 = sales order, 22 = purchase order, 23 = sales quotation, 1470000113 = purchase request. Add a CASE expression for readable names.
- Rejected or approved requests are missing: Status 'W' means pending only. Use 'Y' for approved and 'N' for rejected if you need a history.
Need this report built into SAP Business One?
A saved query answers the question once. We build custom SAP Business One add-ons: UI API screens, DI API and Service Layer logic, on SQL Server and HANA. Or hire a SAP Business One developer for the whole job, fixed price per phase.
Related queries
Table reference: OUSR table (Users)
Three steps, no signup
Copy the right version
Use the SQL Server tab for MS SQL databases and the HANA tab for SAP B1 on HANA.
Open Query Generator
In SAP Business One go to Tools → Queries → Query Generator, paste and click Execute.
Save and share
Click Save, pick a category and give the query a name. Your team can run it from Query Manager.
Questions about this tool
How do I run the documents waiting for approval query in SAP Business One?
Copy the version that matches your database, open Tools → Queries → Query Generator, paste it in the SQL box and click Execute. Save it to reuse it later.
Which tables does this query use?
It reads OWDD, OUSR from the standard SAP Business One schema. No user-defined fields are needed.
Can this be turned into a dashboard or alert?
Yes. We turn queries into Crystal reports, Excel reports that refresh themselves, SAP B1 alerts or WhatsApp messages for managers.
Built for SAP Business One teams
Need this inside SAP Business One?
We build add-ons, reports and integrations for SAP B1 on SQL Server and HANA. Tell us what you need and get a fixed price, usually within 24 hours.
