Alert Management in SAP Business One: Automate Business Notifications with SQL - featured image

Publications

Alert Management in SAP Business One: Automate Business Notifications with SQL

Hector Pincheira

Hector Pincheira

CIO | CTO
Digital Strategy & Technology Innovation

items

Does your company find out about problems when it is already too late?

The automatic alerts in SAP Business One are one of the most powerful resources in the system and, at the same time, one of the most underused. Every day, thousands of companies have SAP B1 installed, data updated in real time, and even so… nobody notices that a customer is 45 days past due until the finance manager reviews it manually at month end.

The real cost, then, is not in the lost data but in the late reaction. An overdue invoice caught after 3 days can be fixed. Caught after 60 days, it is already a cash flow problem that affects entire operations.

In this tutorial you will learn step by step how to configure automatic alerts in SAP Business One using the Alert Management system with custom SQL queries. By the end you will have real alerts running to monitor overdue receivables, unshipped orders and margins below the threshold your company defines.

SAP Business One automatic alerts - business monitoring dashboardSAP Business One automatic alerts - business monitoring dashboard
SAP B1 Alert Management turns real-time data into actionable notifications for the teams.

Why automatic alerts in SAP Business One are a strategic tool

The Alert Management module in SAP Business One is not simply a notification mechanism. It is, in effect, an operational intelligence system that turns static data into signals for action. Configured properly, the company stops being reactive and becomes proactive about its own information.

Yet most SAP B1 users never configure it beyond the system default alerts. That means they are leaving one of the most valuable resources of the ERP on the table. The concrete benefits of implementing custom SQL alerts include shortening the collection cycle by detecting overdue invoices automatically without relying on manual reviews; controlling the shipping chain by notifying when orders have gone more than N days without a delivery; monitoring margins in real time before a sales order with compromised profitability turns into an invoice; and proactively managing due dates for payables, warranties and contracts with enough lead time to act.

Prerequisites before starting

To follow this tutorial you need SAP Business One version 9.0 or higher (on SQL Server or SAP HANA), access to the Query Manager or Query Generator (Tools → Queries → Query Generator), administration rights in SAP B1 (or authorized access to Administration → Alerts Management), and access to the server SMTP settings if you want alerts sent by email.

How the Alert Management system works in SAP B1

SAP Business One Alert Management works on a simple principle: it runs a SQL query at defined intervals and, if the query returns rows, it sends notifications to the configured users. The real power, though, comes from the fact that the SQL query can be as specific and elaborate as the business requires.

The workflow is as follows: first you create and save a SQL query in the Query Manager, then you link that query to an alert in the Alerts Management module, and finally you define who receives the notification, how often and through which channel (internal SAP messages or email). The main system tables involved in this process are OALR (alert trigger records), OAIB (alert inbox per user), OAOB (messages sent by alerts) and ALR1 (recipients configured per alert).

Step 1: Create the SQL Query in the Query Manager

Next, go to Tools → Queries → Query Generator. In SAP B1 the Query Manager is your starting point for every custom alert. The query you save here will be the trigger condition of the alert: if it returns rows, the alert fires; if it returns no rows, nothing happens.

As a first example, we will create an alert for overdue customer invoices. This is one of the highest operational impact alerts in any company, because it connects directly with cash flow and commercial management.

Query 1: Overdue Customer Invoices (Accounts Receivable)

First, the query finds every sales invoice (table OINV) with an open balance and a due date earlier than today. It also filters only documents in Open status (DocStatus = ‘O’) with an open amount greater than zero.

SQL Server

-- Overdue customer invoices - SQL Server
-- For Alert Management: fires when the query returns rows
SELECT TOP 50
    T0.DocNum          AS 'Invoice No.',
    T0.CardCode        AS 'Customer Code',
    T0.CardName        AS 'Customer',
    T0.DocDate         AS 'Posting Date',
    T0.DocDueDate      AS 'Due Date',
    DATEDIFF(DAY, T0.DocDueDate, GETDATE()) AS 'Days Overdue',
    T0.DocTotal        AS 'Invoice Total',
    T0.PaidToDate      AS 'Paid',
    (T0.DocTotal - T0.PaidToDate) AS 'Open Balance',
    T1.SlpName         AS 'Sales Employee'
FROM OINV T0 WITH (NOLOCK)
INNER JOIN OSLP T1 ON T0.SlpCode = T1.SlpCode
WHERE T0.DocStatus = 'O'
  AND T0.DocDueDate < GETDATE()
  AND (T0.DocTotal - T0.PaidToDate) > 0
ORDER BY DATEDIFF(DAY, T0.DocDueDate, GETDATE()) DESC

SAP HANA

-- Overdue customer invoices - SAP HANA
-- For Alert Management: fires when the query returns rows
SELECT TOP 50
    T0."DocNum"          AS "Invoice No.",
    T0."CardCode"        AS "Customer Code",
    T0."CardName"        AS "Customer",
    T0."DocDate"         AS "Posting Date",
    T0."DocDueDate"      AS "Due Date",
    DAYS_BETWEEN(T0."DocDueDate", CURRENT_DATE) AS "Days Overdue",
    T0."DocTotal"        AS "Invoice Total",
    T0."PaidToDate"      AS "Paid",
    (T0."DocTotal" - T0."PaidToDate") AS "Open Balance",
    T1."SlpName"         AS "Sales Employee"
FROM OINV T0
INNER JOIN OSLP T1 ON T0."SlpCode" = T1."SlpCode"
WHERE T0."DocStatus" = 'O'
  AND T0."DocDueDate" < CURRENT_DATE
  AND (T0."DocTotal" - T0."PaidToDate") > 0
ORDER BY DAYS_BETWEEN(T0."DocDueDate", CURRENT_DATE) DESC
LIMIT 50

To save this query, click Save inside the Query Manager, give it a descriptive name such as «ALERT – Overdue AR Invoices» and save it in the «Financial Alerts» category.

Query 2: Sales Orders Not Shipped (More Than 5 Days)

Second, this query finds open sales orders that have gone more than 5 days without a delivery. It is therefore essential for logistics operations and for customer service level commitments. The 5-day threshold is adjustable to each company operating cycle.

SQL Server

-- Sales orders unshipped for more than 5 days - SQL Server
SELECT TOP 30
    T0.DocNum          AS 'Order No.',
    T0.CardName        AS 'Customer',
    T0.DocDate         AS 'Order Date',
    T0.DocDueDate      AS 'Committed Delivery Date',
    DATEDIFF(DAY, T0.DocDate, GETDATE()) AS 'Days Without Shipment',
    T0.DocTotal        AS 'Order Value',
    T1.SlpName         AS 'Sales Employee',
    T0.Comments        AS 'Remarks'
FROM ORDR T0 WITH (NOLOCK)
LEFT JOIN OSLP T1 ON T0.SlpCode = T1.SlpCode
WHERE T0.DocStatus = 'O'
  AND T0.CANCELED = 'N'
  AND DATEDIFF(DAY, T0.DocDate, GETDATE()) > 5
ORDER BY DATEDIFF(DAY, T0.DocDate, GETDATE()) DESC

SAP HANA

-- Sales orders unshipped for more than 5 days - SAP HANA
SELECT TOP 30
    T0."DocNum"          AS "Order No.",
    T0."CardName"        AS "Customer",
    T0."DocDate"         AS "Order Date",
    T0."DocDueDate"      AS "Committed Delivery Date",
    DAYS_BETWEEN(T0."DocDate", CURRENT_DATE) AS "Days Without Shipment",
    T0."DocTotal"        AS "Order Value",
    T1."SlpName"         AS "Sales Employee",
    T0."Comments"        AS "Remarks"
FROM ORDR T0
LEFT JOIN OSLP T1 ON T0."SlpCode" = T1."SlpCode"
WHERE T0."DocStatus" = 'O'
  AND T0."CANCELED" = 'N'
  AND DAYS_BETWEEN(T0."DocDate", CURRENT_DATE) > 5
ORDER BY DAYS_BETWEEN(T0."DocDate", CURRENT_DATE) DESC
LIMIT 30

Query 3: Sales Orders With Gross Margin Below the Defined Threshold

This way you can spot orders with compromised profitability before they become invoices. This alert is especially valuable in companies where sales reps have room to grant discounts, since it lets you step in before the margin reaches negative territory.

SQL Server

-- Sales orders with gross margin below 15% - SQL Server
-- Adjust the 15 threshold to your company's minimum margin policy
SELECT TOP 20
    T0.DocNum           AS 'Order No.',
    T0.CardName         AS 'Customer',
    T0.DocDate          AS 'Date',
    T0.DocTotal         AS 'Sales Total',
    SUM(T1.GrssProfit)  AS 'Gross Margin $',
    ROUND(
        CASE WHEN T0.DocTotal > 0
             THEN (SUM(T1.GrssProfit) / T0.DocTotal) * 100
             ELSE 0 END, 2
    )                   AS '% Margin',
    T2.SlpName          AS 'Sales Employee'
FROM ORDR T0 WITH (NOLOCK)
INNER JOIN RDR1 T1 ON T0.DocEntry = T1.DocEntry
LEFT JOIN OSLP T2 ON T0.SlpCode = T2.SlpCode
WHERE T0.DocStatus = 'O'
  AND T0.CANCELED = 'N'
  AND T0.DocTotal > 0
GROUP BY T0.DocNum, T0.CardName, T0.DocDate, T0.DocTotal, T2.SlpName
HAVING CASE WHEN T0.DocTotal > 0
            THEN (SUM(T1.GrssProfit) / T0.DocTotal) * 100
            ELSE 0 END < 15
ORDER BY CASE WHEN T0.DocTotal > 0
              THEN (SUM(T1.GrssProfit) / T0.DocTotal) * 100
              ELSE 0 END ASC

SAP HANA

-- Sales orders with gross margin below 15% - SAP HANA
-- Adjust the 15 threshold to your company's minimum margin policy
SELECT TOP 20
    T0."DocNum"           AS "Order No.",
    T0."CardName"         AS "Customer",
    T0."DocDate"          AS "Date",
    T0."DocTotal"         AS "Sales Total",
    SUM(T1."GrssProfit")  AS "Gross Margin $",
    ROUND(
        CASE WHEN T0."DocTotal" > 0
             THEN (SUM(T1."GrssProfit") / T0."DocTotal") * 100
             ELSE 0 END, 2
    )                     AS "% Margin",
    T2."SlpName"          AS "Sales Employee"
FROM ORDR T0
INNER JOIN RDR1 T1 ON T0."DocEntry" = T1."DocEntry"
LEFT JOIN OSLP T2 ON T0."SlpCode" = T2."SlpCode"
WHERE T0."DocStatus" = 'O'
  AND T0."CANCELED" = 'N'
  AND T0."DocTotal" > 0
GROUP BY T0."DocNum", T0."CardName", T0."DocDate", T0."DocTotal", T2."SlpName"
HAVING CASE WHEN T0."DocTotal" > 0
            THEN (SUM(T1."GrssProfit") / T0."DocTotal") * 100
            ELSE 0 END < 15
ORDER BY CASE WHEN T0."DocTotal" > 0
              THEN (SUM(T1."GrssProfit") / T0."DocTotal") * 100
              ELSE 0 END ASC
LIMIT 20
SAP Business One automatic alerts - business notification setupSAP Business One automatic alerts - business notification setup
Well-configured alerts turn the ERP into an active monitoring system, not just a transaction recorder.

Step 2: Configure the Automatic Alerts in SAP Business One

Once the queries are saved in the Query Manager, the next step is to create the alerts. To do that, go to Administration → Alerts Management. In more recent versions it may appear as Administration → System Initialization → Alerts.

To configure each alert, click «New» to create an alert, give it a descriptive name (e.g. «Alert – Overdue Invoices»), select the priority (High, Medium or Low) according to how critical the event is, tick the «Active» box so the alert is running, click «Open Saved Query» and select the query created in Step 1, set the execution frequency (from every minute to monthly), select the recipients on the Users tab, define the notification channel (internal SAP message or email), and save the alert with Ctrl+S.

Step 3: Enable Email Notifications

For alerts to reach email as well as appearing in the SAP B1 message inbox, you need to configure the SMTP server. This setting is made in Administration → System Initialization → General Settings → Mail tab.

If you do not have access to the SMTP configuration, the SAP B1 internal messaging alerts are fully functional and reach the users' inbox directly inside the system. Once SMTP is configured, on the Alerts Management screen you can tick the «E-Mail» option for each recipient.

Query 4: Vendor Invoices Coming Due (AP)

It is not only sales that benefits from alerts. For finance, spotting vendor invoices due in the next 7 days is just as critical for planning payments and avoiding arrears with strategic suppliers.

SQL Server

-- Vendor invoices coming due (next 7 days) - SQL Server
SELECT TOP 30
    T0.DocNum          AS 'Vendor Invoice No.',
    T0.CardCode        AS 'Vendor Code',
    T0.CardName        AS 'Vendor',
    T0.DocDate         AS 'Posting Date',
    T0.DocDueDate      AS 'Due Date',
    DATEDIFF(DAY, GETDATE(), T0.DocDueDate) AS 'Days To Due',
    T0.DocTotal        AS 'Invoice Total',
    (T0.DocTotal - T0.PaidToDate) AS 'Balance Due',
    T0.Comments        AS 'Reference'
FROM OPCH T0 WITH (NOLOCK)
WHERE T0.DocStatus = 'O'
  AND T0.DocDueDate BETWEEN GETDATE() AND DATEADD(DAY, 7, GETDATE())
  AND (T0.DocTotal - T0.PaidToDate) > 0
ORDER BY T0.DocDueDate ASC

SAP HANA

-- Vendor invoices coming due (next 7 days) - SAP HANA
SELECT TOP 30
    T0."DocNum"          AS "Vendor Invoice No.",
    T0."CardCode"        AS "Vendor Code",
    T0."CardName"        AS "Vendor",
    T0."DocDate"         AS "Posting Date",
    T0."DocDueDate"      AS "Due Date",
    DAYS_BETWEEN(CURRENT_DATE, T0."DocDueDate") AS "Days To Due",
    T0."DocTotal"        AS "Invoice Total",
    (T0."DocTotal" - T0."PaidToDate") AS "Balance Due",
    T0."Comments"        AS "Reference"
FROM OPCH T0
WHERE T0."DocStatus" = 'O'
  AND T0."DocDueDate" BETWEEN CURRENT_DATE AND ADD_DAYS(CURRENT_DATE, 7)
  AND (T0."DocTotal" - T0."PaidToDate") > 0
ORDER BY T0."DocDueDate" ASC
LIMIT 30

Advanced variations and use cases

The alert system supports practically any condition you can express in SQL. High-value scenarios companies implement frequently include warranty expiration alerts, to catch services or equipment expiring in the next 30 days and contact the customer in time; credit limit alerts, when a customer receivables balance exceeds the limit set on their master record, before new documents are issued; alerts for documents stuck in approval, when purchase orders have been waiting more than X hours for authorization, signaling a bottleneck; and inventory discrepancy alerts, when the theoretical stock in the system differs from what was recorded in physical counts using user-defined fields.

As a result, Alert Management becomes the operational intelligence layer that connects every ERP module with the people responsible for each area, delivering the right information at the right moment.

Best practices and common mistakes

Control the volume of alerts per user. A user who receives 200 alerts a day ends up ignoring all of them. Design your queries with tight filters: set day thresholds, minimum amounts and real priorities. One relevant alert has more impact than ten noisy ones.

Set the frequency to match how critical the data really is. Not every alert needs to run every minute. Overdue collection alerts can run once a day at 8:00 AM. Credit limit alerts, on the other hand, may need hourly execution. Always match the frequency to the real operational impact of the event you are monitoring.

Avoid the most common mistake: queries that always return rows. If your query returns results constantly even when there is no real alert condition, the system will send notifications non-stop. That creates alert fatigue and makes users ignore them. Make sure the query returns rows only when a real condition requires attention.

Clean up the OAIB history periodically. The OAIB table accumulates one record for every alert trigger for every user. In companies with frequent alerts and multiple recipients, this table can grow considerably. As a result, this can impact connection times to the system. It is advisable to implement a maintenance task that deletes OAIB records older than 30 days.

Document every alert you create. Record in an internal document which alert exists, which SQL query it uses, who receives it and why it was created in the first place. This is essential for future maintenance of the system, especially when the IT team changes or when SAP B1 is upgraded.

SAP Business One automatic alerts - notification best practicesSAP Business One automatic alerts - notification best practices
Configuring alerts with well-defined criteria is the difference between a system that alerts and one that only generates noise.

Official SAP resources

To go deeper into the alert system configuration and the system tables, these official resources are the most relevant:

Conclusion: From Passive ERP to Active Monitoring System

SAP Business One Alert Management is the difference between an ERP that stores data and an ERP that actively works for your company. Every hour that passes without alerts configured is an hour in which your system holds critical information nobody is using to decide in time.

The four queries presented in this article —overdue customer invoices, unshipped orders, margins below threshold, and vendor invoices coming due— are the starting point of a real monitoring system. Each one is adapted for both SQL Server and SAP HANA environments, ready to implement directly in your Query Manager today.

If you are a member of Strategic Circle, you get access to the complete library of advanced queries for SAP B1, including variants filtered by branch, by sales employee, by item category, with dynamic parameters, and much more. Do not let your ERP be just a transaction recorder. Put it to work as the operational intelligence system it was always meant to be.

Automatic alerts solve the task, not the decision: that is the subject of The Last Knocker-Upper: Why Automating Managerial Work Fails in Your Company.

Most Read

Ballena jorobada bajo el agua con su aleta pectoral extendida: la esperanza en la tecnología y la biomimética
La ballena que volvió: la esperanza en la tecnología y la que no cabe en un tablero
SAP data in ChatGPT: an open door at the far end of a dark room
The Tab Next Door: The SAP Data in ChatGPT That Nobody Authorized
SAP Business One Purchase Price Variance - featured image of the tutorial
SAP Business One Purchase Price Variance: Detect the Inflation in Your Buying Costs
QlikSense format changeovers: actual minutes against the standard
QlikSense Format Changeovers: the Minutes Nobody Bills
QlikSense buttons and actions: executive dashboard with indicators
QlikSense Buttons and Actions: the Dashboard that Runs the Meeting
SAP Business One Internal Reconciliation - featured image of the tutorial
SAP Business One Internal Reconciliation: Clear False Open Items

RELATED ARTICLES