Start a project

Overdue customer invoices

Open invoices past their due date, with days overdue and the customer phone number.

Tables: OINV, OCRDUse: Daily collection calls and reminder emails.

Tool

SELECT T0.DocNum, T0.CardCode, T0.CardName, T1.Phone1, T0.DocDueDate,
  DATEDIFF(day, T0.DocDueDate, GETDATE()) AS DaysOverdue,
  T0.DocTotal - T0.PaidToDate AS OpenAmount
FROM OINV T0
INNER JOIN OCRD T1 ON T0.CardCode = T1.CardCode
WHERE T0.DocStatus = 'O' AND T0.CANCELED = 'N' AND T0.DocDueDate < GETDATE()
ORDER BY DaysOverdue DESC
Need your UDFs in this report, or a dashboard? We extend it for your company.Customize it →

What this query answers

The collections assistant starts the day with a call list: which invoices are past due, by how many days, how much is open and which number to dial. The most overdue invoices come first.

Sample output

Illustrative demo values. Your columns are the same; the numbers come from your company.

DocNumCardCodeCardNamePhone1DocDueDateDaysOverdueOpenAmount
3051C50000Summit Supplies+1 555 01422026-07-161003150
3124C40000Blue Harbor Foods+1 555 01882026-08-28571800
3190C20000Acme Trading+1 555 01012026-09-24305300
3233C30000Northwind Retail2026-10-14102450

SQL Server vs SAP HANA

DATEDIFF(day, ..., GETDATE()) becomes DAYS_BETWEEN(..., CURRENT_TIMESTAMP), and the filter DocDueDate < GETDATE() becomes < CURRENT_TIMESTAMP. HANA can sort by the quoted alias "DaysOverdue" just like SQL Server.

Common errors and fixes

  • Invoices due today show up as overdue with 0 days: GETDATE() and CURRENT_TIMESTAMP include the time, so a due date of today at 00:00 is already smaller. Compare with the date only: CAST(GETDATE() AS date) on SQL Server, CURRENT_DATE on HANA.
  • Phone column is empty for some customers: Phone1 comes from the business partner master (OCRD). If your team stores numbers on the contact person, join OCPR on T0.CntctCode and use its Cellolar or Tel1 field.

Need this report built into SAP Business One?

A saved query answers the question once. We build B2B customer portals for SAP Business One: customers see their prices, stock, order status, invoices and statements, and their orders land in SAP as sales orders. Or hire a SAP Business One developer for the whole job, fixed price per phase.

Finance

Related queries

Table reference: OINV table (A/R Invoice (header)) · OCRD table (Business Partners)

How it works

Three steps, no signup

1

Copy the right version

Use the SQL Server tab for MS SQL databases and the HANA tab for SAP B1 on HANA.

2

Open Query Generator

In SAP Business One go to Tools → Queries → Query Generator, paste and click Execute.

3

Save and share

Click Save, pick a category and give the query a name. Your team can run it from Query Manager.

FAQ

Questions about this tool

How do I run the overdue customer invoices 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 OINV, OCRD 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.

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.