SAP Business One Blanket Agreements: Purchase and Sales Blanket Agreements with SQL - tutorial featured image

Publications

SAP Business One Blanket Agreements: Purchase and Sales Blanket Agreements with SQL

Hector Pincheira

Hector Pincheira

CIO | CTO
Digital Strategy & Technology Innovation

items

SAP Business One Blanket Agreements It is the functionality that turns a signed contract into a living object within the ERP. Imagine this scene: in January, you closed an annual contract with your main client for 12,000 units at a frozen price. Eight months later, the sales manager asks how much has been shipped and how much is left. No one answers with certainty. Someone opens a spreadsheet that was filled out by an assistant who no longer works at the company. And the answer arrives late, incomplete, and without traceability.

That gap costs real money. It costs you discounts you weren't entitled to, contracts that expired after the 60% requirement was met, and negotiations for the next period conducted blindly. However, the module is already included in your license. Most companies simply don't activate it.

SAP Business One Blanket Agreements - signing a master contract between company and customer
A framework agreement only generates value when the ERP controls it; on paper, it is merely an intention.

What the global agreements module really solves

A blanket agreement is a framework contract: a volume, amount, or price commitment with a customer or vendor over a defined period. In SAP Business One, the agreement does not post journal entries or affect inventory. It acts as a container of conditions that marketing documents consume.

Therefore, every time you issue an order, delivery, or invoice against that partner, the system can link the line to the agreement, apply the agreed-upon price, and accumulate the executed quantity. In this way, you get three things that previously lived in Excel: the correct price without depending on the salesperson's memory, the remaining balance updated in real time, and complete traceability of which document consumed which part of the contract.

The business impact is direct. In addition to eliminating margin leakage caused by incorrectly entered prices, the module allows you to anticipate non-compliance before it’s too late to react. A contract with the 40% for the open interest and the 80% for the time value consumed is a trading alert, not historical data.

Prerequisites before creating your first agreement

Before opening the form, check four conditions. Below is the minimum list:

  • AuthorizationsIn Administration → System Initialization → Authorizations, enable access to Blanket Agreement for the corresponding sales and purchasing profiles.
  • Business Partner Master Datathe customer or supplier must exist and be active. In addition, it is advisable to have their base price list defined in order to detect deviations later.
  • Item MasterThe contract codes must exist with their correct unit of measurement. An agreement for 12,000 units makes no sense if the item is transacted in boxes.
  • Agreed accounting criterionDefine with finance if the agreement controls quantity, amount, or both. That decision changes the configuration and, above all, changes the report they will see later.

Step by step: Create a global sales agreement

Step 1. Go to Sales – Customers → Global agreement. The form opens in creation mode.

Step 2. Select the customer code. The system populates the name, currency, and payment terms from the master data. Verify the currency: a dollar contract with a partner configured in pesos generates conversion discrepancies that are impossible to explain later.

Step 3. Define the type of agreement. The option General control only the total committed amount, without item details. The option Specific It requires the line-by-line detail with quantities and prices. For real operational control, choose Specific. The General version works when you negotiate an annual purchase amount without defining the product mix.

Step 4. Choose the methodby item or by groups of items. The grouping method is useful when the contract commits to the volume of an entire family, for example the entire spare parts line, without fixing the exact SKU.

Step 5. Set the start and end dates, and the signature date. These dates are not decorative: they determine the window in which documents can be charged to the agreement. An order dated outside the range will not consume the contract.

Step 6. Load the lines into the items tab. For each line, define the code, planned quantity, agreed unit price, and, if applicable, the distribution by periods. Consequently, the system will later be able to compare what was committed against what was executed with monthly or quarterly granularity.

Step 7. Change the state Approved. This point is critical: while the agreement remains in draft or on hold, the marketing documents will not consume it. Many implementations fail here and the team concludes, erroneously, that the module does not work.

Step 8. Issue a sales order to the same customer with an item from the contract. SAP Business One will propose linking it to the agreement and will apply the agreed price. Confirm the link and check that the agreement field is populated on the row.

The global purchasing agreement: the same engine, another angle

The path is Purchasing – Suppliers → Global Agreement, and the logic is identical. However, the managerial value changes in nature. In sales, you control your customer's compliance. In purchasing, you control two different things: that your supplier respects the negotiated price and that your own organization concentrates its purchases where volume was negotiated.

For example, if you bought the discount for 5,000 annual units and your plant managers bought 1,800 from that supplier and 3,000 from another due to an emergency, you lost the discount and were also exposed to a contractual claim. The global agreement, queried with SQL, exposes that leakage in minutes.

SAP Business One Blanket Agreements - partial deliveries consuming a master contract
Each partial shipment consumes the contract. Without automatic accumulation, the actual balance is an estimate.

The tables: where the contract really lives

The global agreement is stored in two main tables. The header resides in OOAT and includes partner, dates, status, and type. The detail lies in OAT1, with one row per committed item, its planned quantity, its accumulated quantity, and the agreed price. The join is performed using OAT1.AgrNo = OOAT.AbsID.

In addition, the marketing documents keep the reference to the agreement in the AgrNo field of their lines: RDR1 for orders, DLN1 for deliveries, and INV1 for invoices. That field is the key that allows auditing compliance document by document.

Before copying any query, verify the exact names in your version. Column names vary slightly between releases and this query saves you half an hour of trial and error:

SQL Server

-- Actual structure of the global agreement tables
SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE
FROM   INFORMATION_SCHEMA.COLUMNS
WHERE  TABLE_NAME IN ('OOAT','OAT1')
ORDER  BY TABLE_NAME, ORDINAL_POSITION;

SAP HANA

-- Actual structure of the global agreement tables
SELECT "TABLE_NAME", "COLUMN_NAME", "DATA_TYPE_NAME"
FROM   "SYS"."TABLE_COLUMNS"
WHERE  "SCHEMA_NAME" = CURRENT_SCHEMA
  AND  "TABLE_NAME" IN ('OOAT','OAT1')
ORDER  BY "TABLE_NAME", "POSITION";

compliance dashboard by item

This query delivers the real status of each contracted line: committed, fulfilled, pending, progress percentage, and remaining days. It is the report that should reach the commercial management every Monday.

SQL Server

SELECT
    T0.AbsID                                AS [Agreement],
    T0.BPCode                               AS [Partner],
    T2.CardName                             AS [Name],
    CONVERT(VARCHAR(10), T0.StartDate, 103) AS [Start],
    CONVERT(VARCHAR(10), T0.EndDate,   103) AS [End],
    DATEDIFF(DAY, GETDATE(), T0.EndDate)    AS [Days_Remaining],
    T1.ItemCode                             AS [Item],
    T3.ItemName                             AS [Description],
    T1.PlanQty                              AS [Committed],
    T1.CumQty                               AS [Completed],
    T1.PlanQty - T1.CumQty                  AS [Outstanding],
    CAST(100.0 * T1.CumQty / NULLIF(T1.PlanQty, 0) AS DECIMAL(10,2)) AS [Percentage_Completion],
    T1.UnitPrice                            AS [Agreed_Price]
FROM      OOAT T0
INNER JOIN OAT1 T1 ON T1.AgrNo    = T0.AbsID
INNER JOIN OCRD T2 ON T2.CardCode = T0.BPCode
LEFT  JOIN OITM T3 ON T3.ItemCode = T1.ItemCode
WHERE  T0.Status  = 'A'
  AND  T0.EndDate >= GETDATE()
ORDER  BY [Progress_Pct] ASC, [Days_Remaining] ASC;

SAP HANA

SELECT
    T0."AbsID"    AS "Agreement",
    T0."BPCode"   AS "Partner",
    T2."CardName" AS "Name",
    TO_VARCHAR(T0."StartDate", 'DD/MM/YYYY') AS "Start",
    TO_VARCHAR(T0."EndDate",   'DD/MM/YYYY') AS "End",
    DAYS_BETWEEN(CURRENT_DATE, T0."EndDate") AS "Remaining_Days",
    T1."ItemCode" AS "Item",
    T3."ItemName" AS "Description",
    T1."PlanQty"  AS "Committed",
    T1."CumQty"   AS "Fulfilled",
    T1."PlanQty" - T1."CumQty" AS "Pending",
    ROUND(100.00 * T1."CumQty" /
          (CASE WHEN T1."PlanQty" = 0 THEN NULL ELSE T1."PlanQty" END), 2) AS "Progress_Pct",
    T1."UnitPrice" AS "Agreed_Price"
FROM      OOAT T0
INNER JOIN OAT1 T1 ON T1."AgrNo"    = T0."AbsID"
INNER JOIN OCRD T2 ON T2."CardCode" = T0."BPCode"
LEFT  JOIN OITM T3 ON T3."ItemCode" = T1."ItemCode"
WHERE  T0."Status"  = 'A'
  AND  T0."EndDate" >= CURRENT_DATE
ORDER  BY "Progress_Pct" ASC, "Remaining_Days" ASC;

How to read it. The "Avance_Pct" column, sorted from lowest to highest, places the worst-performing items at the top. Furthermore, "Days_Remaining" turns the problem into an urgent matter: a 45% progress rate with 300 days remaining is manageable; the same 45% with only 40 days remaining is a surefire failure.

contract risk traffic light

Isolated progress is deceiving. What matters is comparing the executed volume against the time consumed. Therefore, this query cross-references both percentages and classifies each agreement into three states.

SQL Server

SELECT
    T0.AbsID    AS [Agreement],
    T2.CardName AS [Partner],
    DATEDIFF(DAY, T0.StartDate, T0.EndDate) AS [Total_Days],
    DATEDIFF(DAY, T0.StartDate, GETDATE())  AS [Elapsed_Days],
    CAST(100.0 * DATEDIFF(DAY, T0.StartDate, GETDATE())
       / NULLIF(DATEDIFF(DAY, T0.StartDate, T0.EndDate), 0) AS DECIMAL(10,2)) AS [Time_Pct],
    CAST(100.0 * SUM(T1.CumQty)
       / NULLIF(SUM(T1.PlanQty), 0) AS DECIMAL(10,2)) AS [Volume_Pct],
    CASE
      WHEN 100.0 * SUM(T1.CumQty) / NULLIF(SUM(T1.PlanQty), 0)
         >= 100.0 * DATEDIFF(DAY, T0.StartDate, GETDATE())
          / NULLIF(DATEDIFF(DAY, T0.StartDate, T0.EndDate), 0) THEN 'ON TRACK'
      WHEN 100.0 * SUM(T1.CumQty) / NULLIF(SUM(T1.PlanQty), 0)
         >= 0.80 * (100.0 * DATEDIFF(DAY, T0.StartDate, GETDATE())
          / NULLIF(DATEDIFF(DAY, T0.StartDate, T0.EndDate), 0)) THEN 'ATTENTION'
      ELSE 'RISK'
    END AS [Traffic_Light]
FROM      OOAT T0
INNER JOIN OAT1 T1 ON T1.AgrNo    = T0.AbsID
INNER JOIN OCRD T2 ON T2.CardCode = T0.BPCode
WHERE  T0.Status = 'A'
  AND  GETDATE() BETWEEN T0.StartDate AND T0.EndDate
GROUP  BY T0.AbsID, T2.CardName, T0.StartDate, T0.EndDate
ORDER  BY [Volume_Pct] ASC;

SAP HANA

SELECT
    T0."AbsID"    AS "Agreement",
    T2."CardName" AS "Partner",
    DAYS_BETWEEN(T0."StartDate", T0."EndDate") AS "Total_Days",
    DAYS_BETWEEN(T0."StartDate", CURRENT_DATE) AS "Elapsed_Days",
    ROUND(100.00 * DAYS_BETWEEN(T0."StartDate", CURRENT_DATE)
        / (CASE WHEN DAYS_BETWEEN(T0."StartDate", T0."EndDate") = 0 THEN NULL
                ELSE DAYS_BETWEEN(T0."StartDate", T0."EndDate") END), 2) AS "Time_Pct",
    ROUND(100.00 * SUM(T1."CumQty")
        / (CASE WHEN SUM(T1."PlanQty") = 0 THEN NULL
                ELSE SUM(T1."PlanQty") END), 2) AS "Volume_Pct",
    CASE
      WHEN 100.00 * SUM(T1."CumQty") / (CASE WHEN SUM(T1."PlanQty") = 0 THEN NULL ELSE SUM(T1."PlanQty") END)
         >= 100.00 * DAYS_BETWEEN(T0."StartDate", CURRENT_DATE)
          / (CASE WHEN DAYS_BETWEEN(T0."StartDate", T0."EndDate") = 0 THEN NULL
                  ELSE DAYS_BETWEEN(T0."StartDate", T0."EndDate") END) THEN 'ON TRACK'
      WHEN 100.00 * SUM(T1."CumQty") / (CASE WHEN SUM(T1."PlanQty") = 0 THEN NULL ELSE SUM(T1."PlanQty") END)
         >= 0.80 * (100.00 * DAYS_BETWEEN(T0."StartDate", CURRENT_DATE)
          / (CASE WHEN DAYS_BETWEEN(T0."StartDate", T0."EndDate") = 0 THEN NULL
                  ELSE DAYS_BETWEEN(T0."StartDate", T0."EndDate") END)) THEN 'ATTENTION'
      ELSE 'RISK'
    END AS "Status_Light"
FROM      OOAT T0
INNER JOIN OAT1 T1 ON T1."AgrNo"    = T0."AbsID"
INNER JOIN OCRD T2 ON T2."CardCode" = T0."BPCode"
WHERE  T0."Status" = 'A'
  AND  CURRENT_DATE BETWEEN T0."StartDate" AND T0."EndDate"
GROUP  BY T0."AbsID", T2."CardName", T0."StartDate", T0."EndDate"
ORDER  BY "Volume_Pct" ASC;

This is how you transform a descriptive list into a management tool. The "AT RISK" traffic light does not describe the past: it demands a sales call this week.

Query 3: price leakage against the agreed price

This is where the money appears. This query compares the invoiced price with the agreement price and quantifies the variance in currency. However, remember that it only detects documents actually linked to the agreement.

SQL Server

SELECT
    T0.DocNum   AS [Invoice],
    CONVERT(VARCHAR(10), T0.DocDate, 103) AS [Date],
    T0.CardCode AS [Partner],
    T2.AbsID    AS [Agreement],
    T1.ItemCode AS [Item],
    T1.Quantity AS [Quantity],
    T1.PriceBefDi AS [Billed_Price],
    T3.UnitPrice  AS [Agreed_Price],
    T1.PriceBefDi - T3.UnitPrice AS [Unit_Variance],
    CAST((T1.PriceBefDi - T3.UnitPrice) * T1.Quantity AS DECIMAL(19,2)) AS [Total_Impact]
FROM      OINV T0
INNER JOIN INV1 T1 ON T1.DocEntry = T0.DocEntry
INNER JOIN OOAT T2 ON T2.AbsID    = T1.AgrNo
INNER JOIN OAT1 T3 ON T3.AgrNo    = T2.AbsID AND T3.ItemCode = T1.ItemCode
WHERE  ISNULL(T1.AgrNo, 0) > 0
  AND  ABS(T1.PriceBefDi - T3.UnitPrice) > 0.01
  AND  T0.DocDate >= DATEADD(MONTH, -12, GETDATE())
ORDER  BY [Total_Impact] ASC;

SAP HANA

SELECT
    T0."DocNum"   AS "Invoice",
    TO_VARCHAR(T0."DocDate", 'DD/MM/YYYY') AS "Date",
    T0."CardCode" AS "BusinessPartner",
    T2."AbsID"    AS "Agreement",
    T1."ItemCode" AS "Item",
    T1."Quantity" AS "Quantity",
    T1."PriceBefDi" AS "Billed_Price",
    T3."UnitPrice"  AS "Agreed_Price",
    T1."PriceBefDi" - T3."UnitPrice" AS "Unit_Variance",
    ROUND((T1."PriceBefDi" - T3."UnitPrice") * T1."Quantity", 2) AS "Total_Impact"
FROM      OINV T0
INNER JOIN INV1 T1 ON T1."DocEntry" = T0."DocEntry"
INNER JOIN OOAT T2 ON T2."AbsID"    = T1."AgrNo"
INNER JOIN OAT1 T3 ON T3."AgrNo"    = T2."AbsID" AND T3."ItemCode" = T1."ItemCode"
WHERE  IFNULL(T1."AgrNo", 0) > 0
  AND  ABS(T1."PriceBefDi" - T3."UnitPrice") > 0.01
  AND  T0."DocDate" >= ADD_MONTHS(CURRENT_DATE, -12)
ORDER  BY "Total_Impact" ASC;

the sales that were never charged to the contract

This is the most uncomfortable finding and, consequently, the most valuable one. It detects documents issued to the agreement partner, with agreement items, within the validity period of the agreement, but without a link. That is: volume that the contract should have accumulated and did not.

SQL Server

SELECT
    T2.AbsID    AS [Agreement],
    T0.CardCode AS [Partner],
    T1.ItemCode AS [Item],
    COUNT(DISTINCT T0.DocEntry) AS [Unallocated_Docs],
    SUM(T1.Quantity)  AS [Non_Accumulated_Quantity],
    CAST(SUM(T1.LineTotal) AS DECIMAL(19,2)) AS [Non_Accumulated_Amount]
FROM      OINV T0
INNER JOIN INV1 T1 ON T1.DocEntry = T0.DocEntry
INNER JOIN OOAT T2 ON T2.BPCode   = T0.CardCode AND T2.Status = 'A'
INNER JOIN OAT1 T3 ON T3.AgrNo    = T2.AbsID    AND T3.ItemCode = T1.ItemCode
WHERE  ISNULL(T1.AgrNo, 0) = 0
  AND  T0.DocDate BETWEEN T2.StartDate AND T2.EndDate
GROUP  BY T2.AbsID, T0.CardCode, T1.ItemCode
ORDER  BY [Non_Accumulated_Amount] DESC;

SAP HANA

SELECT
    T2."AbsID"    AS "Agreement",
    T0."CardCode" AS "Partner",
    T1."ItemCode" AS "Item",
    COUNT(DISTINCT T0."DocEntry") AS "Unallocated_Docs",
    SUM(T1."Quantity") AS "Unaccumulated_Quantity",
    ROUND(SUM(T1."LineTotal"), 2) AS "Unaccumulated_Amount"
FROM      OINV T0
INNER JOIN INV1 T1 ON T1."DocEntry" = T0."DocEntry"
INNER JOIN OOAT T2 ON T2."BPCode"   = T0."CardCode" AND T2."Status" = 'A'
INNER JOIN OAT1 T3 ON T3."AgrNo"    = T2."AbsID"    AND T3."ItemCode" = T1."ItemCode"
WHERE  IFNULL(T1."AgrNo", 0) = 0
  AND  T0."DocDate" BETWEEN T2."StartDate" AND T2."EndDate"
GROUP  BY T2."AbsID", T0."CardCode", T1."ItemCode"
ORDER  BY "Unaccumulated_Amount" DESC;

If this query returns rows, you don't have a system problem: you have a process problem. The ERP did what it was asked to do. Someone, at the counter, skipped the linking.

SAP Business One Blanket Agreements - master contract negotiation with suppliers
The next negotiation is won with the data from the previous one, not with the team's memory.

Variations and real-world use cases

Volume-tiered pricing contract. SAP Business One does not handle scale pricing within the agreement. Therefore, the standard practice is to create one agreement per tier, or to combine the agreement with quantity-based special prices in the business partner master data. Document the decision: anyone who comes after will need to understand it.

Master services agreement for recurring services. A 240-hour annual maintenance contract is modeled as a specific agreement on a non-inventory service item. In this way, each hour invoice consumes the balance, and the customer sees a target account statement.

Distribution by periods. When the contract commits to monthly deliveries, load the period-by-period distribution. As a result, the report stops comparing the annual total and starts comparing what was supposed to correspond to August against what was actually shipped in August. That detail changes the conversation with the client.

Economic group with several companies. An agreement belongs to a business partner, not a group. If your customer purchases through three legal entities, you will need three agreements and a consolidated report by group. Query 1 solves this by adding OCRD.GroupCode to the grouping.

Best practices and common mistakes

  • The state rules. A draft agreement consumes nothing. Also, periodically review approved agreements whose end date has already passed: they still appear in poorly filtered reports.
  • Do not use the agreement as a price list. The agreement sets conditions for a specific contract. If you need permanent prices for all customers in a segment, that is a price list, not a global agreement.
  • Validate the unit of measure. The most expensive and silent mistake: committing 12,000 units and shipping in boxes of 12. The system will accumulate 1,000 and the contract will appear unfulfilled.
  • Define who links. The linkage occurs when the document is issued. Therefore, if the vendor omits it, the data is lost. Reinforce the process with an alert or validation in SP_TransactionNotification.
  • Watch out for cancellations. A credit memo on a linked invoice should reverse the accumulation. Verify that behavior in your version before blindly trusting the balance.
  • Close formally. Upon contract expiration, change the status to Finished or Terminated. An unmaintained agreement master data becomes unusable within two years.

Official SAP resources

Conclusion: the contract is no longer a PDF

The difference between a company that negotiates well and one that negotiates blindly is rarely commercial talent. It is the information available on the day of the negotiation. A master agreement archived as a PDF tells you nothing. That same agreement uploaded as a global contract, with its linked documents and control queries, tells you exactly how much that client complied with, how much margin slipped away, and what terms they deserve for the next period.

Implement SAP Business One Blanket Agreements It does not require a project or an external consultant. It requires a management decision: stop managing contracts from memory. Start with your three largest contracts, upload them this week, and run Query 2. The traffic light system will tell you, in less than a minute, how much that spreadsheet that no one was updating was really worth.

This tutorial is part of the Circulo Estrategico. If you want the rest of the library of SAP Business One queries and practical guides, you already have access: go through the full category and take away the control panel your management is waiting for.

Most Read

QlikSense Hierarchy: parent-child chart of accounts expanded by levels
QlikSense Hierarchy: the Chart of Accounts That Doesn't Add Up
QlikSense Sum TOTAL: share of each family over the total
QlikSense Sum TOTAL: the Percentage That Changes When You Filter
SAP Business One Inventory Revaluation - featured image of the tutorial
SAP Business One Inventory Revaluation: Fix Wrongly Loaded Costs
Empty chamber with wooden benches: the counterweight that required being present to be used
The Veto You Had to Say in Person: Your Decisions With No Counterweight
SAP Business One customizations - featured image of the pre-upgrade audit tutorial
SAP Business One Customizations: Pre-Upgrade Audit
SAP Business One Customer Concentration - featured image of the tutorial
SAP Business One Customer Concentration: Measure Your Risk with SQL

RELATED ARTICLES