DUE TO SPAM, SIGN-UP IS DISABLED. Goto Selfserve wiki signup and request an account.
- Created by Swapnil Shah, last modified on Jun 27, 2025
OFBIZ-13242 - Getting issue details... STATUS
Introduction
Material Requirements Planning (MRP) is a cornerstone of efficient manufacturing and supply chain management. In Apache OFBiz, the MRP engine provides a robust mechanism to simulate inventory levels over time and generate requirements to ensure that the right materials and products are purchased or produced when needed. This document explains how the MRP engine in Apache OFBiz functions, with a focus on its simulation-based logic and decision-making process.
Key Inputs to the MRP Engine
- Quantity on Hand (QOH)
QOH refers to the tangible, available inventory of a product or component at a specific facility or group of facilities—whether produced in-house or procured externally.
When the MRP engine calculates a requirement, it deducts QOH from the total demand to generate only the shortfall.
Example
If 100 units are needed and 30 are already in stock (QOH), MRP will recommend producing or buying the remaining 70 units.
- Sales Order
A Sales Order represents a confirmed customer demand and serves as a key input for the MRP engine.
- Purchase orders
A purchase order is a formal document created to request and track the procurement of products or services from a supplier, including details like items, quantity, price, and delivery terms.
- Minimum Stock
This is the minimum inventory threshold set for a product at a specific facility. When the Quantity on Hand (QOH) falls below this level, the system can automatically generate a replenishment requirement—that could be served through a Purchase Order and/or Production Run.
Example
If the minimum stock for a Wheel Assembly is 50 units and the current QOH is 30 units, the MRP will generate a requirement for at least 20 more units.
- Reorder Quantity (ROQ)
ROQ is a fixed restocking amount defined for a product. Regardless of how small the shortfall is, Apache OFBiz will recommend ordering the full ROQ when a Purchase Order is triggered.
Example
If ROQ for Stickers is set to 100 units and you only need 1 more unit (with 99 already in stock), the system will still recommend procuring 100 units, not just 1.
- Sales Forecast
A sales forecast is a prediction of how many products or services a business expects to sell in the future. It helps the company plan ahead—like how much to produce, buy, or keep in stock—based on past sales, current trends, and market conditions.
Unlike a sales order, which is a confirmed request from a customer, a sales forecast is just an estimate of what might be sold.
Approved Production Run
An Approved Production Run is a confirmed internal production job in Apache OFBiz. From the perspective of the MRP engine, it plays a dual role in the planning process:
- It represents incoming supply of the finished good or sub-components item, helping to offset demand.
- It also generates outgoing demand for the raw materials and sub-components required to execute the production run.
This means the MRP engine accounts for it in two directions:
- Supply for the finished good (Incoming Job Quantity)
- Demand for required raw materials and components (Outgoing Job Quantity)
Example
If there’s a demand for 100 skateboards and an Approved Production Run already covers 40 units, the MRP engine will recommend producing the remaining 60 only if no stock is available through existing quantity on hand or other pre-approved production plans. At the same time, the system will recognize that producing 40 skateboards requires 80 stickers (2 units per skateboard), 40 decks, etc., and will calculate requirements for those components accordingly.
- Lead Time
Lead time is the number of days it takes to procure a product from a supplier. It is used to calculate when a purchase requirement must be initiated so that the product is available when needed.
- MRP Recommendation
An MRP Recommendation is a system-generated suggestion created during an MRP engine run in Apache OFBiz. It indicates that a specific quantity of an item should be produced (for internally produced items) or procured (for externally sourced items) to meet anticipated demand. These recommendations are stored in the system as Requirements, but they remain in a proposed state until explicitly approved. As long as a recommendation is not approved:
- No Production Run is created (for internally produced items)
- No Purchase Order is created (for externally sourced items)
When the MRP engine is run again, Apache OFBiz first removes all previously generated recommendations (Un approved Requirements). This keeps the planning data clean and prevents requirement duplication. However, the system still re-evaluates the latest demand and supply gaps—such as from open sales orders, current inventory, and scheduled production—and regenerates recommendations where needed.
Example
Suppose you receive a sales order for 500 shirts. Your inventory has only 100 shirts available. On the first MRP run, Apache OFBiz generated a requirement to procure 400 more shirts.
However, this recommendation is not acted upon by the planning team. The next day, the MRP engine is run again.
- The old 400-unit requirement is deleted by the system.
- But because the sales order is still open and no new purchase order was added, Apache OFBiz recalculates the shortage and again recommends procuring 400 units.
The result is a new requirement, not a duplicate—but it reflects the same underlying demand that still hasn't been fulfilled.
At the heart of the Apache OFBiz MRP engine is a simple but powerful concept: The MRP engine simulates every event that adds to or depletes inventory, and projects what the Quantity on Hand (QOH) will be for each product.
Factors That Affect Inventory
The MRP engine considers all events that will impact inventory levels:
Events that decrease QOH (Demand)
- Sales Orders (SO): Customer shipments reduce QOH.
- Outgoing Job Requirements: Internal production consumes raw materials/components which will be consumed in production run.
- Transfer Shipments Out: Inventory moved to other warehouses.
- Sales Forecasts (SF): Anticipated future customer demand based on historical or projected trends. These can be included to plan ahead of actual sales orders.
- Minimum Stock: Safety stock levels that trigger replenishment when simulated stock falls below the threshold. These act as implicit demand signals to maintain buffer inventory.
Events that increase QOH (Supply)
- Purchase Orders (PO): Expected deliveries from suppliers.
- Incoming Job Quantity: Completion of internal production jobs.
- Transfer Shipments In: Inventory received from other warehouses.
- Approved Requirements: Requirements that have been reviewed and approved. Once approved, they are treated as confirmed incoming supply, either through a Production Run (for internal items) or a Purchase Order (for external items).
Before diving into how the MRP engine operates, it's essential to understand the types of requirements generated by the MRP Engine.
Types of Requirements Generated by MRP
When the MRP Engine is executed in Apache OFBiz, it generates two main types of Requirements, depending on whether a product or component is produced internally or sourced externally.
- Internal Requirements
Internal Requirements are generated for items that are produced in-house using defined routing tasks, including both finished goods and sub-components that must be produced internally as part of a larger assembly.
Example
If a skateboard consists of multiple items, including a deck, and both the skateboard and the deck are produced in-house, then the MRP engine will generate internal requirements for each item. One internal requirement will be created for the finished product (the skateboard), and another for the sub-component (the deck).Once approved, production managers can create and schedule Production Runs in Apache OFBiz for both the skateboard and the deck, based on these requirements.
- External Requirements
External Requirements are generated for items that are not produced internally and must be procured from suppliers. This item can be raw materials used in internal production runs (e.g., stickers for skateboards)
Example
If ABC Company receives a sales order for 500 skateboards and purchases fully assembled boards from a supplier (rather than making them in-house), the MRP engine will generate an external requirement for 500 units.
Once approved, these Requirements can be converted into Purchase Orders by the procurement team within Apache OFBiz.
The MRP engine intelligently distinguishes between what items can be produced and what items can be purchased. This ensures an optimized procurement and production requirement plan that balances internal capacity and supplier dependencies.
Default Year Offset in Apache OFBiz
The Default Year Offset is a special setting used during the MRP Engine run in Apache OFBiz to manage the priority of sales orders without a delivery date.
The setting helps determine how these undated orders are handled in planning:
- If the offset is set to 1, the system treats the order as low priority, assigning a virtual delivery date 365 days in the future.
- If the offset is set to 0, the order is treated as high priority, assuming the delivery date is today.
Note: Sales orders usually include an estimated delivery date. However, in some cases, such as when data is imported from an external system, this date may be missing.
This mechanism ensures that sales orders without dates are managed intelligently, without disrupting material planning or production schedules.
Calculation of Required Quantities and Required-By Dates in Apache OFBiz MRP Engine
After understanding the key inputs used by the MRP engine, it's important to look at how Apache OFBiz determines the quantity that needs to be produced or purchased during a MRP run.
MRP engine algorithm uses the following formula to calculate the Required Quantity for each item:
Simulated Stock = QOH + PO Qty + Incoming Job Qty - (SO Qty + SF Qty + Outgoing Job Qty)
Where:
- QOH (Quantity on Hand): The current inventory level of the product when MRP is executed
- PO Qty (Purchase Order Quantity): Quantities of the product expected to be received from pending purchase orders.
- Incoming Job Qty: Quantities expected to be produced from Approved Production Run or Approved Requirements
- SO Qty (Sales Order Quantity): Quantities committed to fulfill customer orders.
- SF Qty (Sales Forecast Quantity) : Quantities anticipated from future customer demand.
- Outgoing Job Qty: Quantities that will be consumed as part of Production Run (e.g., raw materials used in sub-components)
If:
Simulated Stock < Minimum Stock
Then a requirement is generated to ensure stock levels are maintained above the defined minimum threshold level.
Requirement Quantity Formula:
Requirement Quantity = MAX(Reorder Qty, (Minimum Stock - Simulated Stock))
This formula simulates what inventory requirements will be based on future promises, balancing incoming supply and outgoing demand to assess if there's a projected shortfall.
Note
Max(A, B) means the system chooses whichever is higher between the Reorder Quantity and the Minimum Stock less Simulated Stock
This formula ensures that:
- Demand is met in full
- Reorder policies are respected
- Inventory shortfalls are covered
- Existing supply (in stock or incoming) is deducted before generating a new requirement
If Simulated Stock > Minimum Stock
It means that your available and incoming inventory is sufficient to meet current and near-future demand.
What happens in this case?- No requirement is generated by the MRP engine.
- The system interprets that there is no immediate or projected material shortfall.
- As a result:
- No new Purchase Order is recommended.
- No new Production Run is suggested.
How does the MRP Engine decide to create a Consolidated or Separate Requirements?
- Consolidated Requirement:
The MRP Engine creates a single, combined requirement if multiple sales orders for the same product have the same estimated delivery date or no delivery date specified.
Example:
Suppose two sales orders for Skateboards—one for 50 units and another for 30 units. If both have the same estimated delivery date of June 10, or no estimated delivery date, the MRP Engine will generate one consolidated requirement for 80 units.
- Separate Requirements:
If the estimated delivery dates differ, and MRP is run, the engine treats each sales order separately and generates individual requirements.
Example:
One sales order for 50 Skateboards has an estimated delivery date of June 10, and another sales order for 30 Skateboards has an estimated delivery date of June 15. Now, when MRP is executed, it will generate two separate requirements—one for 50 units (June 10) and another for 30 units (June 15).
Simulation of MRP Run on May 23, 2025
In addition to calculating how much of an item is required, Apache OFBiz’s MRP engine also determines when each requirement is needed—known as the Requirement Start Date. This ensures that the materials are available just in time for production or customer delivery, minimizing stockouts and inventory holding costs.
Lets take an example of the Skateboard. Here is BOM for a Skateboard:
BOM for One Skateboard | |||
|---|---|---|---|
Item Name | Item Type | Qty | Build or Buy |
Sticker | Finished Good | 2 | Purchased externally |
Warranty Card | Finished Good | 1 | Purchased externally |
Transfer | Finished Good | 1 | Purchased externally |
Deck | Sub-component | 1 | Produced internally |
Now, let’s apply the Requirement calculation formula to three practical examples to understand how Apache OFBiz calculates required quantities and determines the Requirement Start Date for different products.
1. Skateboard (Finished Good)
Suppose a Sales Order (SO) for 100 skateboards is received today i.e. May 23, with an estimated delivery date of July 1 and Skateboards are going to be produced internally.
MRP not only checks inventory and incoming quantities but also evaluates the operation tasks (also known as routing tasks) defined for producing the skateboard. These operation tasks may include setup time and run time, which help estimate the total time required to complete the production job of Skateboard.
For example, if the operation task indicates it takes 2 hours to produce one skateboard, assuming an 8-hour working day, it would take 25 days to produce 100 skateboards. Therefore, the production must start 25 days before the delivery date, assuming there is no holiday within these 25 days. Calculated Start Date for Production Job
Estimated Delivery Date of SO - 25 days
July 1 - 25 days = June 6
So the Required By Date for the internal requirement (production run) is June 6.
Here on 23 May first MRP is executed .
Now, let's take a look at the current state of the system.
- QOH = 10 units
- PO Qty = 0 units
- Incoming Job Qty = 5 units
- SO Qty = 100 units
- Outgoing Job Qty = 0 (as skateboard is never used as raw-material/sub-assembly for any product)
- Minimum Stock = 5 units
- ROQ = 6 units
Simulated Stock = QOH + PO Qty + Incoming Job Qty - (SO Qty + Outgoing Job Qty)
Simulated Stock for Skateboard = 10 + 0 + 5 – 100 – 0 = -85 units
Shortfall = = MAX(6, (5 – (–85))) units
Requirement = MAX(6, 90) = 90 units of skateboard
Requirement Start Date: Since the skateboard is the product that will need to be produced internally, the requirement Start Date will be the start date of the production job. i.e. June 8 (To produce 90 skateboards by July 1, 2025, counting 22.5 calendar days backward (with no holidays), production must start by mid-day on June 8)
Required By Date: 30 June
Note: A Production Run for 90 units will be created and approved in the system. After this, MRP2 is executed, which generates requirements for the Sticker, Warranty Card, Transfer & Deck sub-assembly components: Glue, Core, Ply, and Face.
Now, let’s calculate the requirements generated by the second MRP run.
2. Sticker (Purchased Component)
Stickers are procured externally and are required to produce skateboards. Assume each skateboard needs 2 stickers. The lead time to procure stickers is 7 days.
Inputs
- QOH = 50 units
- PO Qty = 0 units (No existing Purchase Order exists in the system)
- Incoming Job Qty = 0 unit (Since it's not produced)
- SO Qty = 0 units (Stickers are not sold directly)
- Outgoing Job Qty = 180 units (will be used for the production job of 90 skateboards)
- Minimum Stock = 20 units
- ROQ = 100 units
- Lead Time = 7 days
Simulated Stock = QOH + PO Qty + Incoming Job Qty - (SO Qty + Outgoing Job Qty)
Simulated Stock of Sticker = 50 + 0 + 0 – 0 – 180 = –130 units
Shortfall = MAX(100, (20 – (–130)))
Requirement = MAX(100, (20 – (–130))) units
= MAX(100, 150) = 150 units of stickers
In the previous example, we determined that the production run for skateboards must start on June 8 based on operation task duration.
Since stickers are used in this production run, they must be available before the production starts.
Requirement Start Date = Start date of Production job - Lead Time
Requirement Start Date of Sticker = June 8 - 7 days = 1 June
Required By Date: 31 May
So the stickers must be procured and available by 1 June (assuming no holidays in between)
3. Deck (Produced Sub-Component)
Decks are made in-house and are required to produce skateboards. Each skateboard needs 1 deck.
Inputs
- QOH = 20 units
- PO Qty = 0 unit (no Purchase Order, as its produced internally)
- Incoming Job Qty = 0 unit (assuming no existing Approved Production Run in the system)
- SO Qty = 0 unit (Decks are not sold directly)
- Outgoing Job Qty = 90 units (will be used for the production job of 90 skateboards)
- Minimum Stock = 20 units
- ROQ = 50 units
Assumption : The components of deck (glue, face, ply & core) are available in required quantity.
Simulated Stock of Deck = 20 + 0 + 0 – 0 – 90 = –70 units
Shortfall = MAX(50, (20 – (–70)))
Requirement = MAX(50, 90)= 90 units of decks
Requirement Start Date: Initially, decks are needed at the start of the parent production run for skateboards, which is June 8
However, since decks are produced internally, MRP evaluates the operation task associated with deck production. Suppose it takes 1 day to produce 20 decks, then 4.5 days (production starts mid day of June 3) are needed to produce 90 decks.
To ensure they are ready by June 8, production of decks must begin 5 days earlier assuming there is no holiday in between.
Calculated Start Date for Production Job
June 8 - 5 days = June 3
So, the internal requirement for decks will have a Requirement Start Date of June 3 and Required By Date of 2 June. Decks are required at the start of the parent production run for skateboards, which is June 8.
These examples demonstrate how Apache OFBiz calculates both the quantity and the timing of each requirement, ensuring every part arrives or is made just in time to support production and delivery plans.
How MRP Output Evolves with System Events Over Time
To understand how the MRP engine updates its recommendations with each run, let’s examine a timeline from May 23 to May 28 using Skateboard, Sticker, and Deck as examples.
Timeline of Events
Date | Event | Notes |
May 23 | Sales Order placed for 100 skateboards (delivery date: July 1) | From the initial sales order of 23 May |
May 23 | MRP run triggered and generated the requirement for 90 skateboards. | Refer to the calculation above to see how the requirement for 90 skateboards is generated |
May 24 | Production Run for 90 skateboards is created and approved | Production of 90 Skateboards will address the requirement of Skateboards needed inSales Order |
For simplicity, we assume that all components are procured and production is completed within a single day. In practice, this process can span multiple days. Systems status as on May 25 for skateboard QOH: 0 | PO Qty: 0 | Incoming Job Qty: 0 | SO Qty: 0 | Outgoing Job Qty: 0 | Minimum Stock: 5 | ROQ: 6 | ||
May 25 | New Sales Order for 30 skateboards (delivery date: July 5) | Received new sales order |
May 26 | New Sales Order for 20 skateboards (delivery date: July 6) | |
May 27 | New Sales Order for 50 skateboards (delivery date: July 7) | |
May 28 | MRP is run again Note: Minimum stock was added only to the Sales Order dated 25 May, whether it is for a finished product or a sub-component. This is because the minimum stock is consumed and needs to be replenished. It is applied just once and remains until consumed by another demand | Requirements generated by the MRP on 28 May for
|
What Happens When MRP Runs on May 28
- Skateboard
- The Production Run created on May 24 covers the May 23 SO (90 units).
- New Sales Orders total 100 skateboards (30 + 20 + 50) from 25, 26, 27 May.
- MRP generates three separate internal requirements:
- 35 skateboards (SO delivery date: July 5 → total 10.5 days needed: 1.75 days for decks, 8.75 days for skateboards → deck production starts by June 23 → skateboard production starts June 25 → so Requirement Start Date: June 25, Required By Date: July 4)
- 20 skateboards (SO delivery date: July 6 → total 6 days needed: 1 day for decks, 5 days for skateboards → deck production starts by June 30 → skateboard production starts July 1 →so Requirement Start Date: July 1, Required By Date: July 5 ).
- 50 skateboards (SO delivery date: July 7 → total 15 days needed: 2.5 days for decks, 12.5 days for skateboards → deck production starts by June 22 → skateboard production starts June 25 →so Requirement Start Date: June 25, Required By Date: July 6 ).
- Sticker
- Needed in a 1:2 ratio with skateboards and procured externally with a 7-day lead time.
- MRP generates external requirements:
- 80 stickers (Requirement = (0 + 30*2 + 20) - (0 + 0 + 0) = 80 units) → needed in production by June 27 → Requirement Start Date: June 20, Required By Date: June 20
- 40 stickers → needed in production by July 1 → Requirement Start Date: June 24, Required By Date: June 24
- 100 stickers → needed in production by June 25 → Requirement Start Date: June 18, Required By Date: June 18
- Deck
- Needed in a 1:1 ratio with skateboards.
- MRP generates corresponding internal requirements:
- 50 decks for SO of 30 skateboards and 20 minimum stock→ Requirement Start Date: June 27 → deck production takes 1 day per 20 decks → 2.5 days → production must start by June 24.
- 20 decks for SO of 20 skateboards → deck production takes 1 day per 20 decks → 1 day → Requirement Start Date: July 1 → production starts by June 30
- 50 decks for SO of 50 skateboards → deck production takes 1 day per 20 decks → 2.5 days → Requirement Start Date: June 25 → production starts by June 22
This dynamic simulation capability is one of the MRP engine’s core strengths in Apache OFBiz. Each run considers all recent transactions, approved jobs, and stock updates to deliver fresh and accurate planning insights.
Conclusion
Through the simulation, we've demonstrated how MRP engine calculations respond to different events spread over multiple dates, using the Skateboard, Sticker and Deck as examples. By examining these shifts in demand and supply, we gain a clear understanding of how the MRP engine of Apache OFBiz dynamically adjusts to ensure optimal resource planning and production efficiency.
While this example simplifies the process with just two components, the same principles get applied across the entire production landscape in a live environment, where every event influences the overall manufacturing plan.
The MRP engine in Apache OFBiz doesn't just react to current shortages—it proactively plans by simulating how inventory will be affected over time due to various events in the supply chain. By factoring in all incoming and outgoing events, it ensures that planners can make timely decisions to avoid stockouts or overstock situations and minimize delays in goods deliveries. Whether you're working with purchased goods or produced components, the MRP engine provides the intelligence needed to optimize supply chain operations.
If you're building or customizing an Manufacturing Execution and Planning solution on top of Apache OFBiz, understanding this simulation-driven planning logic is key to leveraging its full potential.