---
id: object/codeunit/5812
type: object
title: Codeunit 5812 "Calculate Standard Cost"
summary: Codeunit 5812 "Calculate Standard Cost" in Base Application (Microsoft.Manufacturing.StandardCost). 24 public procedures, 38 events, 1 event subscribers. Present since at least BC23, still in BC30, changed in BC24-30.
tier: official
language: en
tags:
  - codeunit
  - base application
versions:
  introduced: null
  last_changed: "30"
  deprecated: null
review:
  state: derived
  by: null
  at: null
  flags: []
generated:
  at: "2026-10-11T00:31:51.816Z"
  pipeline: 0.2.0
  prompts: {}
  input_hash: 0cb09ce4ebb89f966810b400c3cd68b22751e1c78b939fcae30d6d96171c0c48
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/Layers/W1/BaseApp/Manufacturing/StandardCost/CalculateStandardCost.Codeunit.al
    title: src/Layers/W1/BaseApp/Manufacturing/StandardCost/CalculateStandardCost.Codeunit.al (releases/29.x)
    date: null
    commit: ea08af5ef2d6a9b5c5af4a029288abbe2c883220
    t: null
    quote: null
links:
  learn: []
  objects: []
  features: []
  topics: []
  localizations:
    - localization/it
  videos: []
  posts: []
  guidelines: []
  changes:
    - change/bcapps/12066
    - change/bcapps/10631
    - change/bcapps/10173
object_type: codeunit
object_id: 5812
name: Calculate Standard Cost
namespace: Microsoft.Manufacturing.StandardCost
app: Base Application
extends: null
first_version: "23"
last_version: "30"
present_in:
  - "23"
  - "24"
  - "25"
  - "26"
  - "27"
  - "28"
  - "29"
  - "30"
changed_in:
  - "24"
  - "25"
  - "26"
  - "27"
  - "28"
  - "29"
  - "30"
source_major: "29"
obsolete: null
countries:
  - it
ms_search_form_ids: []
counts:
  fields: 0
  procedures: 93
  events: 38
  subscribers: 1
relations:
  out: 0
  referenced_by: 0
  pages: 0
  extended_by: 0
  event_subscribers: 3
  calls: 6
  called_by: 3
  implements: 0
---

# Codeunit 5812 "Calculate Standard Cost"

> Codeunit 5812 "Calculate Standard Cost" in Base Application (Microsoft.Manufacturing.StandardCost). 24 public procedures, 38 events, 1 event subscribers. Present since at least BC23, still in BC30, changed in BC24-30.

Base Application · Microsoft.Manufacturing.StandardCost · BC23-30 · [source at ea08af5e](https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/Layers/W1/BaseApp/Manufacturing/StandardCost/CalculateStandardCost.Codeunit.al) · facts from BC29

## Events published

- `OnAfterCalcRtngLineCost(RoutingLine: Record "Routing Line"; MfgItemQtyBase: Decimal; var SLCap: Decimal; var SLSub: Decimal; var SLCapOvhd: Decimal; var StdCostWkshName: Text[50]; var ParentItem: Record Item; CostTime: Decimal; var DirUnitCost: Decimal)` (integration)
  - subscribers: [Codeunit 20514 "Subc. Calc.StandardCost Ext."](../codeunit/20514.md) OnAfterCalcRtngLineCost
- `OnCalcRtngCostSKUOnBeforeCalcRtngLineCostSKU(var RoutingLine: Record "Routing Line"; MfgItemQtyBase: Decimal; var SLCap: Decimal; var SLSub: Decimal; var SLCapOvhd: Decimal; var IsHandled: Boolean)` (integration)
- `OnAfterSetProdBOMFilters(var ProdBOMLine: Record "Production BOM Line"; var PBOMVersionCode: Code[20]; var ProdBOMNo: Code[20])` (integration)
- `OnAfterSetProperties(var NewCalculationDate: Date; var NewCalcMultiLevel: Boolean; var NewUseAssemblyList: Boolean; var NewLogErrors: Boolean; var NewStdCostWkshName: Text[50]; var NewShowDialog: Boolean)` (integration)
  - subscribers: [Codeunit 20514 "Subc. Calc.StandardCost Ext."](../codeunit/20514.md) OnAfterSetProperties
- `OnBeforeCalcItems(var Item: Record Item)` (integration)
- `OnCalcItemsOnBeforeProcessItems(var Item2: Record Item; var NewTempItem: Record Item; var IsHandled: Boolean)` (integration)
- `OnBeforeCalcItem(var Item: Record Item; UseAssemblyList: Boolean; var IsHandled: Boolean)` (integration)
- `OnBeforeCalcMfgItem(var Item: Record Item; var LogErrors: Boolean; StdCostWkshName: Text[50])` (integration)
- `OnBeforeCalcRtngLineCost(var RoutingLine: Record "Routing Line"; MfgItemQtyBase: Decimal; var ParentItem: Record Item)` (integration)
- `OnCalcAssemblyItemOnAfterInitItemCost(var Item: Record Item)` (integration)
- `OnCalcAssemblyItemOnAfterCalcItemRolledupCost(var Item: Record Item)` (integration)
- `OnBeforeTestBOMVersionIsCertified(BOMVersionCode: Code[20]; ProductionBOMHeader: Record "Production BOM Header"; LogErrors: Boolean; var IsHandled: Boolean)` (integration)
- `OnBeforeTestRtngVersionIsCertified(RtngVersionCode: Code[20]; RoutingHeader: Record "Routing Header"; LogErrors: Boolean; var IsHandled: Boolean)` (integration)
- `OnCalcAssemblyItemOnAfterCalcSingleLevelCost(var Item: Record Item)` (integration)
- `OnCalcAssemblyItemOnAfterCalcItemCost(var Item: Record Item; CompItem: Record Item; BOMComponent: Record "BOM Component"; var ComponentQuantity: Decimal; var Level: Integer; var CalcMfgItems: Boolean)` (integration)
- `OnCalcItemOnBeforeShowStrMenu(var Item: Record Item; var ShowStrMenu: Boolean; var NewCalcMultiLevel: Boolean)` (integration)
- `OnCalcItemOnAfterCalcShowConfirm(Item: Record Item; var CalcMfgItems: Boolean; var ShowConfirm: Boolean)` (integration)
- `OnCalcMfgItemOnBeforeCalcRtngCost(var Item: Record Item; Level: Integer; var LotSize: Decimal; var MfgItemQtyBase: Decimal; var SLCap: Decimal)` (integration)
  - subscribers: [Codeunit 20514 "Subc. Calc.StandardCost Ext."](../codeunit/20514.md) OnCalcMfgItemOnBeforeCalcRtngCost
- `OnCalcMfgItemOnBeforeCalculateCosts(var SLMat: Decimal; var SLCap: Decimal; var SLSub: Decimal; var SLCapOvhd: Decimal; var SLMfgOvhd: Decimal; var Item: Record Item; LotSize: Decimal; MfgItemQtyBase: Decimal; Level: Integer; CalculationDate: Date; var RUMat: Decimal)` (integration)
- `OnCalcMfgItemOnAfterCalculateCosts(SingleLevelMaterial: Decimal; SingleLevelCapacity: Decimal; SingleLevelSubcontracted: Decimal; SingleLevelCapacityOverhead: Decimal; SingleLevelMfgOverhead: Decimal; var Item: Record Item; LotSize: Decimal; MfgItemQtyBase: Decimal; Level: Integer; CalculationDate: Date; RolledUpMaterial: Decimal)` (integration)
- `OnCalcProdBOMCostOnAfterCalcCompItemQtyBase(CalculationDate: Date; MfgItem: Record Item; MfgItemQtyBase: Decimal; IsTypeItem: Boolean; var ProdBOMLine: Record "Production BOM Line"; var CompItemQtyBase: Decimal; RtngNo: Code[20]; UOMFactor: Decimal)` (integration)
- `OnCalcProdBOMCostOnAfterCalcMfgItem(var ProdBOMLine: Record "Production BOM Line"; MfgItem: Record Item; MfgItemQtyBase: Decimal; CompItem: Record Item; CompItemQtyBase: Decimal; Level: Integer; IsTypeItem: Boolean; UOMFactor: Decimal; var ParentItem: Record Item)` (integration)
- `OnCalcProdBOMCostOnAfterCalcAnyItem(var ProductionBOMLine: Record "Production BOM Line"; MfgItem: Record Item; MfgItemQtyBase: Decimal; CompItem: Record Item; CompItemQtyBase: Decimal; Level: Integer; IsTypeItem: Boolean; UOMFactor: Decimal; var SLMat: Decimal; var RUMat: Decimal; var RUCap: Decimal; var RUSub: Decimal; var RUCapOvhd: Decimal; var RUMfgOvhd: Decimal)` (integration)
- `OnCalcRtngCostOnBeforeCalcRtngLineCost(var RoutingLine: Record "Routing Line"; ParentItem: Record Item; var LogErrors: Boolean; var IsHandled: Boolean)` (integration)
- `OnCalcRoutingCostPerUnitOnBeforeCalc(Type: Enum "Capacity Type Routing"; var DirUnitCost: Decimal; var IndirCostPct: Decimal; var OvhdRate: Decimal; var UnitCost: Decimal; var UnitCostCalculation: Enum "Unit Cost Calculation Type"; WorkCenter: Record "Work Center"; MachineCenter: Record "Machine Center"; var IsHandled: Boolean)` (integration)
- `OnGetWorkCenterOnBeforeAssignWorkCenterToTemp(var WorkCenter: Record "Work Center"; var TempItem: Record Item temporary; StdCostWkshName: Text[50])` (integration)
- `OnAfterGetItem(var Item: Record Item; StdCostWkshName: Text[50]; IsInBuffer: Boolean)` (integration)
- `OnBeforeSetProperties(var NewCalculationDate: Date; var NewCalcMultiLevel: Boolean; var NewUseAssemblyList: Boolean; var NewLogErrors: Boolean; var NewStdCostWkshName: Text[50]; var NewShowDialog: Boolean)` (integration)
- `OnBeforeCalcProdBOMCost(MfgItem: Record Item; ProdBOMNo: Code[20]; RtngNo: Code[20]; MfgItemQtyBase: Decimal; IsTypeItem: Boolean; Level: Integer; var SLMat: Decimal; var RUMat: Decimal; var RUCap: Decimal; var RUSub: Decimal; var RUCapOvhd: Decimal; var RUMfgOvhd: Decimal; var IsHandled: Boolean; var CalculationDate: Date; var LogErrors: Boolean; var TempRoutingVersion: Record "Routing Version" temporary; var TempProductionBOMVersion: Record "Production BOM Version" temporary)` (integration)
- `OnBeforeDoCalcAssemblyItemPrice(var Item: Record Item; Level: Integer; MaxLevel: Integer; CalcMultiLevel: Boolean; var IsHandled: Boolean)` (integration)
- `OnDoCalcAssemblyItemPriceOnAfterSetBOMCompFilters(var Item: Record Item; var BOMComponent: Record "BOM Component")` (integration)
- `OnCalcProdBOMCostOnBeforeCalcCompItemQtyBase(var ProductionBOMLine: Record "Production BOM Line"; var ParentItem: Record Item; CalculationDate: Date; MfgItem: Record Item; MfgItemQtyBase: Decimal; IsTypeItem: Boolean; var CompItemQtyBase: Decimal; RtngNo: Code[20]; UOMFactor: Decimal)` (integration)
- `OnGetResCostOnBeforeAssignPriceListLineToTemp(var PriceListLine: Record "Price List Line"; var TempItem: Record Item temporary; StdCostWkshName: Text[50])` (integration)
- `OnGetMachineCenterOnBeforeAssignMachineCenterToTemp(var MachineCenter: Record "Machine Center"; var TempItem: Record Item temporary; StdCostWkshName: Text[50])` (integration)
- `OnCalcRtngLineCostOnAfterCalcRoutingCostPerUnit(RoutingLine: Record "Routing Line"; WorkCenter: Record "Work Center"; var MfgItemQtyBase: Decimal; var UnitCostCalculation: Enum "Unit Cost Calculation Type")` (integration)
- `OnCalcRtngLineCostOnBeforeCalcRoutingCostPerUnit(var RoutingLine: Record "Routing Line"; MfgItemQtyBase: Decimal; var WorkCenter: Record "Work Center"; var DirUnitCost: Decimal; var IndirCostPct: Decimal; var OvhdRate: Decimal; var UnitCost: Decimal; var UnitCostCalculation: Enum "Unit Cost Calculation Type"; var ParentItem: Record Item; var IsHandled: Boolean)` (integration)
- `OnCalcItemOnAfterCalculateCosts(var Item: Record Item)` (integration)
- `OnCalcProdBOMCostOnBeforeNextLineIteration(var ProductionBOMLine: Record "Production BOM Line"; PBOMVersionCode: Code[20]; Level: Integer; CompItemQtyBase: Decimal; CompItem: Record Item; SLMat: Decimal)` (integration)

## Event subscriptions

- OnValidateNoByType subscribes to Table "Standard Cost Worksheet" OnAfterValidateEvent (No.)

## Procedures

- `SetProperties(NewCalculationDate: Date; NewCalcMultiLevel: Boolean; NewUseAssemblyList: Boolean; NewLogErrors: Boolean; NewStdCostWkshName: Text[50]; NewShowDialog: Boolean)`
- `TestPreconditions(var Item: Record Item; var TempNewProductionBOMVersion: Record "Production BOM Version" temporary; var NewRtngVersionErrBuf: Record "Routing Version")`
- `CalcItem(ItemNo: Code[20]; NewUseAssemblyList: Boolean)`
- `CalcItemForNonInventoryValue(var Item: Record Item)` (obsolete 27.0: procedure that was implemented to throw the error has now been identified as unnecessary)
- `CalcSKUForNonInventoryValue(var SKU: Record "Stockkeeping Unit")` (obsolete 27.0: procedure that was implemented to throw the error has now been identified as unnecessary)
- `CalcItemSKU(ItemNo: Code[20]; LocationCode: Code[20]; VariantCode: Code[20])`
- `CalcItems(var Item: Record Item; var NewTempItem: Record Item)`
- `CalcAssemblyItemPrice(ItemNo: Code[20])`
- `CalculateAssemblyCostExp(AssemblyHeader: Record "Assembly Header"; var ExpCost: array[5] of Decimal)`
- `CalcOverHeadAmt(CostAmt: Decimal; IndirectCostPct: Decimal; OverheadRateAmt: Decimal): Decimal`
- `CalcAsmOrderStatistics(AssemblyHeader: Record "Assembly Header"; var Value: array[5, 5] of Decimal)`
- `CalcPostedAsmOrderStatistics(PostedAssemblyHeader: Record "Posted Assembly Header"; var Value: array[5, 5] of Decimal)`
- `CalcRtngLineCost(RoutingLine: Record "Routing Line"; MfgItemQtyBase: Decimal; var SLCap: Decimal; var SLSub: Decimal; var SLCapOvhd: Decimal)`
- `CalcRtngLineCost(RoutingLine: Record "Routing Line"; MfgItemQtyBase: Decimal; var SLCap: Decimal; var SLSub: Decimal; var SLCapOvhd: Decimal; var ParentItem: Record Item)` (internal)
- `CalcRtngLineCostSKU(RoutingLine: Record "Routing Line"; MfgItemQtyBase: Decimal; var SLCap: Decimal; var SLSub: Decimal; var SLCapOvhd: Decimal)` (internal)
- `RunOnBeforeCalcItems(var Item: Record Item)` (internal)
- `RunOnBeforeCalcItem(var Item: Record Item; UseAssemblyList: Boolean; var IsHandled: Boolean)` (internal)
- `RunOnCalcAssemblyItemOnAfterInitItemCost(var Item: Record Item)` (internal)
- `RunOnCalcAssemblyItemOnAfterCalcItemRolledupCost(var Item: Record Item)` (internal)
- `RunOnCalcAssemblyItemOnAfterCalcSingleLevelCost(var Item: Record Item)` (internal)
- `RunOnCalcAssemblyItemOnAfterCalcItemCost(var Item: Record Item; CompItem: Record Item; BOMComponent: Record "BOM Component"; ComponentQuantity: Decimal)` (internal)
- `RunOnAfterGetItem(var Item: Record Item; StdCostWkshName: Text[50]; IsInBuffer: Boolean)` (internal)
- `RunOnBeforeDoCalcAssemblyItemPrice(var Item: Record Item; Level: Integer; MaxLevel: Integer; CalcMultiLevel: Boolean; var IsHandled: Boolean)` (internal)
- `RunOnDoCalcAssemblyItemPriceOnAfterSetBOMCompFilters(var Item: Record Item; var BOMComponent: Record "BOM Component")` (internal)

Plus 30 local procedures.

## Triggers

OnRun

## Calls

From the extracted call graph of BC29 (graphify-al on the snapshot checkout): calls whose target is known from a declared type or an `Object::"Name"` argument. Interface dispatch and calls through events are not counted, so the list is not complete.

- [Codeunit 99000758 "Mfg. Cost Calculation Mgt."](../codeunit/99000758.md) (8 calls: `CalcMfgItem → CalcQtyAdjdForBOMScrap`, `CalcMfgItem → CanIncNonInvCostIntoProductionItem`, `CalcMfgSKU → CalcQtyAdjdForBOMScrap`, …)
- [Codeunit 5402 "Unit of Measure Management"](../codeunit/5402.md) (6 calls: `CalcAssemblyItem → GetQtyPerUnitOfMeasure`, `CalcAssemblyItem → GetResQtyPerUnitOfMeasure`, `CalcProdBOMCost → GetQtyPerUnitOfMeasure`, …)
- [Codeunit 5836 "Cost Calculation Management"](../codeunit/5836.md) (6 calls: `CalcMfgItem → CalcOvhdCost`, `CalcMfgSKU → CalcOvhdCost`, `CalcRtngLineCostSKU → CalcOvhdCost`, …)
- [Codeunit 5804 "ItemCostManagement"](../codeunit/5804.md) (3 calls: `CalcItem → UpdateStdCostShares`, `CalcItemSKU → UpdateStdCostShares`, `CalcItemSKU → UpdateStdCostSharesForSKU`)
- [Codeunit 99000756 "VersionManagement"](../codeunit/99000756.md) (2 calls: `CalcProdBOMCost → GetBOMUnitOfMeasure`, `SetProdBOMFilters → GetBOMVersion`)
- [Codeunit 7001 "Price Calculation Mgt."](../codeunit/7001.md) (1 call: `FindResourceCost → GetHandler`)

## Called by

- [Codeunit 4770 "Create Mfg Item"](../codeunit/4770.md) (2 calls: `CalcStandardCost → CalcItems`, `CalcStandardCost → SetProperties`)
- [Codeunit 99000762 "Mfg. Item Journal Mgt."](../codeunit/99000762.md) (2 calls: `OnAfterOnPreDataItem → CalcItems`, `OnAfterOnPreDataItem → SetProperties`)
- [Report extension 99000781 "Mfg. CalcInventoryValueTest"](../reportextension/99000781.md) (2 calls: `CalculateStandardCost → SetProperties`, `CalculateStandardCost → TestPreconditions`)

## Recent changes

- 2026-10-02 [#12066 Bugs/remove asm inv mfg clean27 tags for wave2 2026](../../changes/bcapps/12066.md) (main, BC30, obsoletion)
- 2026-08-26 [#10631 Integration/main to releases 29.x 31a860b5](../../changes/bcapps/10631.md) (releases/29.x, BC29, feature)
- 2026-08-24 [#10173 [Extensibility Request] issue 30129: expose manufacturing cost calculation events](../../changes/bcapps/10173.md) (main, BC30, feature)

## Across versions

- Present in: BC23-30
- Changed (declaration) in: BC24-30

## Countries that replace it

[IT](../../localizations/it.md)

## Deprecations

- procedure CalcItemForNonInventoryValue: Pending 27.0 (#if not CLEAN27), "procedure that was implemented to throw the error has now been identified as unnecessary"
- procedure CalcSKUForNonInventoryValue: Pending 27.0 (#if not CLEAN27), "procedure that was implemented to throw the error has now been identified as unnecessary"

Source: AL metadata extracted from the code (names, ids, signatures, properties); no code bodies (D10).

## Ask your agent

Procedure bodies are not stored here (D10). The call sections above are our own, per object, from the BC29 call graph. For a procedure body or the calls of one procedure, ask bc-code-atlas (external, by Stefan Maron, MIT; default corpus w1-28), which the bc-observatory plugin connects: `bcatlas_resolve_node(object_type: "codeunit", object_name: "Calculate Standard Cost")`, then `bcatlas_get_procedure_body` or `bcatlas_get_neighbors` on the returned id.
