Explode Multi-Level Bill of Materials Into Planned Orders With Lot Sizes
Last updated: November 29, 2026
Quick Overview
Given finished-good demand, a multi-level bill of materials where subassemblies can be shared by several parents, on-hand stock, and a lot size per material, compute the planned order quantity for every material. Net each material only after all of its parents have passed down requirements, round up to the lot size, and report an error if the BOM contains a cycle.
SAP
November 29, 20260
0
0 solved
Given finished-good demand, a multi-level bill of materials where subassemblies can be shared by several parents, on-hand stock, and a lot size per material, compute the planned order quantity for every material. Net each material only after all of its parents have passed down requirements, round up to the lot size, and report an error if the BOM contains a cycle.
SAP onsite loops for supply chain and manufacturing teams (S/4HANA MRP, Integrated Business Planning) use this because it is the core of material requirements planning. The interviewer is checking whether you realize that a naive recursive explosion nets shared components too early, and whether you fix it with low-level-code ordering, which is a topological sort.
What the Interviewer Expects
- Explains why naive DFS explosion gives wrong results when components are shared and have stock or lot sizes
- Processes materials in topological (low-level code) order so gross requirements are complete before netting
- Applies netting against stock, then rounds up to the lot size with integer math
- Detects cycles in the BOM
- Handles materials that appear only as components or only in stock data
- Gives O(V + E) complexity after sorting
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you add lead times so each planned order also gets a start date?
- How do you handle scrap percentages on components?
- How would you re-plan incrementally when one sales order changes (net change planning)?
- What if lot sizes have a minimum and a maximum instead of a fixed multiple?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
BOM edges parent -> (child, qty_per) form a graph that should be a DAG. For each material: gross requirement is external demand plus planned_order(parent) * qty_per summed over all parents. Net re...
High-Level Design
The trap: exploding each finished good separately with DFS nets the shared component twice, subtracting stock twice and rounding to the lot size twice. Netting is not linear, so the component must see...