---
title: "Codeunit 5870 Calculate BOM Tree"
author: "Jonas Paprotka"
url: https://jonas-paprotka.de/ref/codeunit/5870-calculate-bom-tree/
type: codeunit
id: 5870
name: "Calculate BOM Tree"
app: "Base Application"
namespace: Microsoft.Inventory.BOM.Tree
versions: "17-28"
build: 28.5.54151.54365
source: "https://jonas-paprotka.de/ref/codeunit/5870-calculate-bom-tree/source/29/"
checked: 2026-09-20
subject: "Microsoft Dynamics 365 Business Central"
license: "Content © 2026 Jonas Paprotka. Quote freely with attribution and a link."
---

# Codeunit 5870 Calculate BOM Tree

Jonas Paprotka, https://jonas-paprotka.de/ref/codeunit/5870-calculate-bom-tree/

| | |
| --- | --- |
| App | Base Application |
| Namespace | Microsoft.Inventory.BOM.Tree |
| Versions | 17-28 |
| Source file | Inventory/BOM/Tree/CalculateBOMTree.Codeunit.al |

## Procedures

| Name | Parameters | Returns | Access | Versions | Obsolete | Reason |
| --- | --- | --- | --- | --- | --- | --- |
| GenerateTreeForItems | (var Record Item, var Record BOM Buffer, Option) | - | public | 17-28 | Pending 27.0 | Replaced by procedure GenerateTreeForManyItems |
| GenerateTreeForItem | (var Record Item, var Record BOM Buffer, Date, Option) | - | public | 17-28 | Pending 27.0 | Replaced by procedure GenerateTreeForOneItem() |
| GenerateTreeForAsm | (Record Assembly Header, var Record BOM Buffer, Option) | - | public | 17-28 | Pending 27.0 | Replaced by procedure GenerateTreeForAssemblyHeader() |
| GenerateTreeForProdLine | (Record Prod. Order Line, var Record BOM Buffer, Option) | - | public | 17-28 | Pending 27.0 | Replaced by procedure GenerateTreeForProdOrderLine |
| SetShowTotalAvailability | (Boolean) | - | public | 17-28 | - | - |
| SetItemFilter | (var Record Item) | - | public | 17-28 | - | - |
| InitVars | () | - | public | 27-28 | - | - |
| InitBOMBuffer | (var Record BOM Buffer) | - | public | 27-28 | - | - |
| InitTreeType | (Enum BOM Tree Type) | - | public | 27-28 | - | - |
| GetTreeType | () | Enum BOM Tree Type | public | 27-28 | - | - |
| GenerateTreeForManyItems | (var Record Item, var Record BOM Buffer, Enum BOM Tree Type) | - | public | 27-28 | - | - |
| GenerateTreeForOneItem | (var Record Item, var Record BOM Buffer, Date, Enum BOM Tree Type) | - | public | 27-28 | - | - |
| GenerateTreeForSource | (Variant, var Record BOM Buffer, Enum BOM Tree Type, Enum BOM Structure Show By, Date) | - | public | 27-28 | - | - |
| GenerateTreeForAssemblyHeader | (Record Assembly Header, var Record BOM Buffer, Enum BOM Tree Type) | - | public | 27-28 | Pending 27.0 | Moved to codeunit AsmCalculateBOMTree |
| GenerateTreeForProdOrderLine | (Record Prod. Order Line, var Record BOM Buffer, Enum BOM Tree Type) | - | public | 27-28 | Pending 27.0 | Moved to codeunit MfgCalculateBOMTree |
| CalculateTreeType | (var Record BOM Buffer, Boolean, Enum BOM Tree Type) | - | public | 27-28 | - | - |
| GenerateItemSubTree | (Code[20], var Record BOM Buffer) | Boolean | public | 27-28 | - | - |
| CalcCompDueDate | (Date, Record Item, DateFormula) | Date | public | 27-28 | - | - |
| SetLocationSpecific | (Boolean) | - | public | 27-28 | - | - |
| GetShowTotalAvailability | () | Boolean | public | 27-28 | - | - |
| RunOnAfterGenerateProdCompSubTree | (var Record Item, var Record BOM Buffer, var Record BOM Buffer) | - | internal | 27-28 | - | - |
| RunOnAfterTransferFromProdItem | (var Record BOM Buffer, Record Production BOM Line, var Integer) | - | internal | 27-28 | - | - |
| RunOnAfterTransferFromProdBOM | (var Record BOM Buffer, Record Production BOM Line) | - | internal | 27-28 | - | - |
| RunOnAfterTransferFromProdRouting | (var Record BOM Buffer, var Record Routing Line) | - | internal | 27-28 | - | - |
| RunOnBeforeCalcRoutingLineCosts | (var Record Routing Line, var Decimal, var Decimal, Record Item) | - | internal | 27-28 | - | - |
| RunOnBeforeFilterByQuantityPer | (var Record Production BOM Line, var Boolean, Record BOM Buffer) | - | internal | 27-28 | - | - |
| RunOnBeforeTransferFromProdBOM | (var Record BOM Buffer, var Record Production BOM Line, var Record Item, var Record BOM Buffer, var Integer, Option) | - | internal | 27-28 | - | - |
| RunOnBeforeTransferProdBOMLine | (var Record BOM Buffer, var Record Production BOM Line, var Record Item, var Record BOM Buffer, var Integer, Option, var Boolean) | - | internal | 27-28 | - | - |
| RunOnGenerateAsmHeaderSubTreeOnAfterAsmLineLoop | (var Record BOM Buffer, var Record BOM Buffer) | - | internal | 27-28 | - | - |
| RunOnGenerateProdCompSubTreeOnBeforeExitForNonProdOrder | (Record Item, var Record BOM Buffer, var Boolean) | - | internal | 27-28 | - | - |
| RunOnGenerateProdCompSubTreeOnAfterGenerateItemSubTree | (var Record BOM Buffer, var Record BOM Buffer) | - | internal | 27-28 | - | - |
| RunOnGenerateProdCompSubTreeOnAfterProdBOMLineLoop | (var Record BOM Buffer, var Record BOM Buffer) | - | internal | 27-28 | - | - |
| RunOnGenerateProdCompSubTreeOnBeforeBOMBufferModify | (var Record BOM Buffer, var Record BOM Buffer, Record Item) | - | internal | 27-28 | - | - |
| RunOnCalcRoutingLineCostsOnBeforeBOMBufferAdd | (Record Routing Line, Decimal, Decimal, var Decimal, var Decimal, var Decimal, var Record BOM Buffer) | - | internal | 27-28 | - | - |
| RunOnGenerateProdCompSubTreeOnAfterBOMBufferModify | (var Record BOM Buffer, Record Routing Line, Decimal, Record Item, Record BOM Buffer, Option) | - | internal | 27-28 | - | - |
| RunOnGenerateProdCompSubTreeOnBeforeRoutingLineLoop | (var Record Routing Line, var Record BOM Buffer, var Boolean) | - | internal | 27-28 | - | - |
| RunOnBeforeGenerateProdOrderLineSubTree | (Record Prod. Order Line, var Record BOM Buffer, var Record BOM Buffer, var Boolean, var Boolean) | - | internal | 27-28 | - | - |

## Events

| Kind | Name | Parameters | Versions | Obsolete | Reason |
| --- | --- | --- | --- | --- | --- |
| Integration event | OnAfterFilterBOMBuffer | (var Record Item, var Record BOM Buffer, Date, Option) | 17-28 | - | - |
| Integration event | OnAfterGenerateProdCompSubTree | (var Record Item, var Record BOM Buffer) | 17-18 | - | - |
| Integration event | OnAfterTransferFromProdItem | (var Record BOM Buffer, Record Production BOM Line) | 17 | - | - |
| Integration event | OnAfterTransferFromProdBOM | (var Record BOM Buffer, Record Production BOM Line) | 17-28 | Pending 27.0 | Moved to codeunit MfgCalculateBOMTree |
| Integration event | OnAfterTransferFromProdRouting | (var Record BOM Buffer, Record Routing Line) | 17-20 | - | - |
| Integration event | OnBeforeCalcRoutingLineCosts | (var Record Routing Line, var Decimal, var Decimal, Record Item) | 17-28 | Pending 27.0 | Moved to codeunit MfgCalculateBOMTree |
| Integration event | OnBeforeFilterBOMBuffer | (var Record Item, var Record BOM Buffer, Date, Option, var Boolean) | 17-28 | - | - |
| Integration event | OnBeforeFilterByQuantityPer | (var Record Production BOM Line, var Boolean) | 17-23 | - | - |
| Integration event | OnBeforeTransferFromProdBOM | (var Record BOM Buffer, var Record Production BOM Line, var Record Item, var Record BOM Buffer, var Integer, Option) | 17-28 | Pending 27.0 | Moved to codeunit MfgCalculateBOMTree |
| Integration event | OnBeforeTransferProdBOMLine | (var Record BOM Buffer, var Record Production BOM Line, var Record Item, var Record BOM Buffer, var Integer, Option, var Boolean) | 17-28 | Pending 27.0 | Moved to codeunit MfgCalculateBOMTree |
| Integration event | OnTraverseCostTreeOnAfterAddCost | (var Record BOM Buffer, var Record BOM Buffer) | 17-24 | Pending 22.0 | Replaced with a more generic OnTraverseCostTreeOnAfterAddCosts |
| Integration event | OnCalcRoutingLineCostsOnBeforeBOMBufferAdd | (Record Routing Line, Decimal, Decimal, var Decimal, var Decimal, var Decimal, var Record BOM Buffer) | 17-28 | Pending 27.0 | Moved to codeunit MfgCalculateBOMTree |
| Integration event | OnGenerateProdCompSubTreeOnAfterBOMBufferModify | (var Record BOM Buffer, Record Routing Line, Decimal, Record Item, Record BOM Buffer) | 17-23 | - | - |
| Integration event | OnAfterTransferFromProdItem | (var Record BOM Buffer, Record Production BOM Line, var Integer) | 18-28 | Pending 27.0 | Moved to codeunit MfgCalculateBOMTree |
| Integration event | OnBeforeGenerateTreeForItems | (var Boolean) | 18-28 | - | - |
| Integration event | OnGenerateProdCompSubTreeOnBeforeRoutingLineLoop | (var Record Routing Line, var Record BOM Buffer) | 18-19 | - | - |
| Integration event | OnGenerateTreeForItemLocalOnBeforeCalculateTreeType | (var Record Item, var Record BOM Buffer, var Option, var Integer) | 18-28 | - | - |
| Integration event | OnInitItemAvailDatesOnBeforeCalcAvailableQty | (var Record Item) | 18-28 | - | - |
| Integration event | OnAfterGenerateProdCompSubTree | (var Record Item, var Record BOM Buffer, var Record BOM Buffer) | 19-28 | Pending 27.0 | Moved to codeunit MfgCalculateBOMTree |
| Integration event | OnBeforeGenerateTreeForItemLocal | (var Record Item, Date, Option) | 19 | - | - |
| Integration event | OnGenerateAsmHeaderSubTreeOnAfterAsmLineLoop | (var Record BOM Buffer, var Record BOM Buffer) | 19-28 | Pending 27.0 | Moved to codeunit AsmCalculateBOMTree |
| Integration event | OnGenerateProdCompSubTreeOnAfterGenerateItemSubTree | (var Record BOM Buffer, var Record BOM Buffer) | 19-28 | Pending 27.0 | Moved to codeunit MfgCalculateBOMTree |
| Integration event | OnGenerateProdCompSubTreeOnAfterProdBOMLineLoop | (var Record BOM Buffer, var Record BOM Buffer) | 19-28 | Pending 27.0 | Moved to codeunit MfgCalculateBOMTree |
| Integration event | OnGenerateItemSubTreeOnAfterParentItemGet | (var Record Item) | 19-28 | - | - |
| Integration event | OnGenerateProdCompSubTreeOnBeforeBOMBufferModify | (var Record BOM Buffer, var Record BOM Buffer, Record Item) | 19-28 | Pending 27.0 | Moved to codeunit MfgCalculateBOMTree |
| Integration event | OnBeforeGenerateTreeForItemLocal | (var Record Item, Date, Option, var Record BOM Buffer, var Boolean) | 20-28 | - | - |
| Integration event | OnGenerateProdCompSubTreeOnBeforeRoutingLineLoop | (var Record Routing Line, var Record BOM Buffer, var Boolean) | 20-28 | Pending 27.0 | Moved to codeunit MfgCalculateBOMTree |
| Integration event | OnAfterTransferFromProdRouting | (var Record BOM Buffer, var Record Routing Line) | 21-28 | Pending 27.0 | Moved to codeunit MfgCalculateBOMTree |
| Integration event | OnGenerateProdCompSubTreeOnBeforeExitForNonProdOrder | (Record Item, var Record BOM Buffer, var Boolean) | 21-28 | Pending 27.0 | Moved to codeunit MfgCalculateBOMTree |
| Integration event | OnTraverseCostTreeOnAfterAddCosts | (var Record BOM Buffer, var Record BOM Buffer) | 21-28 | - | - |
| Integration event | OnTraverseTreeOnBeforeCalcAbleToMakeParentAndTopItem | (var Record BOM Buffer, var Record BOM Buffer, var Boolean) | 22-28 | - | - |
| Integration event | OnGenerateBOMCompSubTreeOnBeforeLoopBOMComponents | (Record Item, var Boolean) | 22-28 | - | - |
| Integration event | OnBeforeInitBOMBuffer | (var Record BOM Buffer, var Boolean) | 23-28 | - | - |
| Integration event | OnBeforeFilterByQuantityPer | (var Record Production BOM Line, var Boolean, Record BOM Buffer) | 24-28 | Pending 27.0 | Moved to codeunit MfgCalculateBOMTree |
| Integration event | OnGenerateProdCompSubTreeOnAfterBOMBufferModify | (var Record BOM Buffer, Record Routing Line, Decimal, Record Item, Record BOM Buffer, Option) | 24-28 | Pending 27.0 | Moved to codeunit MfgCalculateBOMTree |
| Integration event | OnCalcAvailabilityOnBeforeUpdateAvailableQty | (var Record BOM Buffer, Decimal, Decimal, var Boolean) | 25-28 | - | - |
| Integration event | OnBeforeGenerateProdOrderLineSubTree | (Record Prod. Order Line, var Record BOM Buffer, var Record BOM Buffer, var Boolean, var Boolean) | 25-28 | Pending 27.0 | Moved to codeunit MfgCalculateBOMTree |
| Integration event | OnGenerateTreeForSource | (Variant, var Record BOM Buffer, Enum BOM Tree Type, Enum BOM Structure Show By, Date, var Record Item, var Integer) | 27-28 | - | - |
| Integration event | OnGenerateItemSubTreeOnSetIsLeaf | (var Record Item, var Record BOM Buffer, var Record Item, var Integer) | 27-28 | - | - |
| Integration event | OnHasBOMStructure | (var Record Item, var Boolean) | 27-28 | - | - |
| Integration event | OnAfterCalcCompDueDate | (var Date, Date, Record Item, DateFormula) | 28 | - | - |
| Integration event | OnTraverseCostTreeOnBeforeAddCosts | (var Record BOM Buffer, var Record BOM Buffer) | 28 | - | - |
| Integration event | OnTraverseCostTreeOnBeforeLastUpdateNodeCosts | (var Record BOM Buffer, var Record BOM Buffer) | 28 | - | - |

## Source

Symbols: Microsoft.BaseApplication.symbols.437dbf0e-84ff-417a-965d-ed2bb9650972, https://dynamicssmb2.pkgs.visualstudio.com/DynamicsBCPublicFeeds/_packaging/MSSymbols/nuget/v3/index.json, highest build per major on 2026-09-20.
AL source 29: https://github.com/microsoft/BCApps, MIT, releases/29.x at a66254c3b8b5bb1cea290dc8f9d097aec4381153.

Jonas Paprotka, 2026-09-20.
