Table of Contents

KVSKBAProductionLib

Summary: Handles Business Central events for Production Library, including Transfer Add Fields On After Validate Prod Order Source No, Check Item Setup On Before Validate Item Jnl Line Item No, and Check Variant Code Blocked On Before Validate Item Jnl Line Variant Code.

Procedures

OnValidateProdOrderLineItemNo(Record Prod. Order Line, Record Prod. Order Line, Record Item) :

Summary: Called when the Item No. field on a Prod. Order Line is validated, to check whether the item is blocked for manufacturing.

procedure OnValidateProdOrderLineItemNo(var ProdOrderLine: Record "Prod. Order Line"; xProdOrderLine: Record "Prod. Order Line"; Item: Record "Item"): 

Parameters:

  • ProdOrderLine: The production order line being validated.
  • xProdOrderLine: The previous state of the production order line.
  • Item: The item record resolved from the new item number.

Remarks: Exits immediately if Item No. is empty. Calls KVSKBAIsBlockedManufacturing to raise an error if the item is blocked.

OnValidateProdOrderCompItemNo(Record Prod. Order Component, Record Prod. Order Component, Record Item) :

Summary: Called when the Item No. field on a Prod. Order Component is validated, to check whether the component item is blocked for manufacturing consumption.

procedure OnValidateProdOrderCompItemNo(var ProdOrderComponent: Record "Prod. Order Component"; xProdOrderComponent: Record "Prod. Order Component"; Item: Record "Item"): 

Parameters:

  • ProdOrderComponent: The production order component being validated.
  • xProdOrderComponent: The previous state of the production order component.
  • Item: The item record resolved from the new item number.

Remarks: Always calls KVSKBAIsBlockedManufConsumption; the caller is responsible for ensuring the item record is already fetched.

CalculateStatusSignalsComplete(Record Production Order) :

Summary: Recalculates production status signals for all non-finished production orders in the company.

procedure CalculateStatusSignalsComplete(var ProductionOrder: Record "Production Order"): 

Parameters:

  • ProductionOrder: The production order record used as a working variable; its original filter/position is restored after processing.

Remarks: Temporarily resets and re-filters the ProductionOrder record to iterate over all orders with Status <> Finished. The original record state is restored via Copy after the loop completes.

CalculateStatusSignals(Record Production Order, Boolean) :

Summary: Recalculates all production status signals (material consumption, labor/output, external orders) and their percentage values for a single released production order, then persists the result via Modify.

procedure CalculateStatusSignals(var ProductionOrder: Record "Production Order"; ShowError: Boolean): 

Parameters:

  • ProductionOrder: The released production order whose signal fields are updated.
  • ShowError: If true, blocking checks on the item will raise an error; if false, errors are suppressed.

Remarks: Calls CalculateStatusMaterial, CalculateStatusCapacity, and CalculateStatusExternalOrders. Signal colors (red/yellow/green) are sourced from Company Information blob fields. Exits without modifying if the item is blocked or if KVSKBAProdNotReady is true.

Events

OnAfterCalculateStatusCapacity(Enum Production Order Status, Code[20], Integer, Option, Decimal, Option, Decimal) :

[IntegrationEvent(false, false)]
local procedure OnAfterCalculateStatusCapacity(ProdOrderStatus: Enum "Production Order Status"; ProdOrderNo: Code[20]; ProdOrderLineNo: Integer; var SignalLaborConsum: Option; var LaborConsumInPercent: Decimal; var SignalLaborOutput: Option; var LaborOutputInPercent: Decimal): 

OnAfterCalculateStatusMaterial(Enum Production Order Status, Code[20], Integer, Option, Decimal) :

[IntegrationEvent(false, false)]
local procedure OnAfterCalculateStatusMaterial(ProdOrderStatus: Enum "Production Order Status"; ProdOrderNo: Code[20]; ProdOrderLineNo: Integer; var SignalMaterialConsum: Option; var MaterialConsumInPercent: Decimal): 

OnAfterCalculateStatusExternalOrders(Code[20], Integer, Option, Decimal, Option, Decimal) :

Summary: Fired after all external order signal and percentage values have been calculated for a production order.

[IntegrationEvent(false, false)]
local procedure OnAfterCalculateStatusExternalOrders(ProdOrderNo: Code[20]; ProdOrderLineNo: Integer; var SignalExternalOrders: Option; var ExternalOrdersInPercent: Decimal; var SignalExternalReply: Option; var ExternalReplyInPercentr: Decimal): 

Parameters:

  • ProdOrderNo: The production order number.
  • ProdOrderLineNo: The production order line number (0 = all lines).
  • SignalExternalOrders: The calculated external order creation signal (Not Started / At Work / Completed). Can be overridden.
  • ExternalOrdersInPercent: The external order creation percentage. Can be overridden.
  • SignalExternalReply: The calculated external output reply signal (Not Started / At Work / Completed). Can be overridden.
  • ExternalReplyInPercentr: The external reply percentage. Can be overridden.

Remarks: Raised by CalculateStatusExternalOrders after purchase orders and capacity entries have been evaluated for all subcontracting routing lines. Use a subscriber to apply custom override logic for external order signals without re-implementing the full calculation.

OnBeforeCalculateStatusCapacity(Enum Production Order Status, Code[20], Integer, Option, Decimal, Option, Decimal, Boolean) :

[IntegrationEvent(false, false)]
local procedure OnBeforeCalculateStatusCapacity(ProdOrderStatus: Enum "Production Order Status"; ProdOrderNo: Code[20]; ProdOrderLineNo: Integer; var SignalLaborConsum: Option; var LaborConsumInPercent: Decimal; var SignalLaborOutput: Option; var LaborOutputInPercent: Decimal; var IsHandled: Boolean): 

OnBeforeCalculateStatusMaterial(Enum Production Order Status, Code[20], Integer, Option, Decimal, Boolean) :

[IntegrationEvent(false, false)]
local procedure OnBeforeCalculateStatusMaterial(ProdOrderStatus: Enum "Production Order Status"; ProdOrderNo: Code[20]; ProdOrderLineNo: Integer; var SignalMaterialConsum: Option; var MaterialConsumInPercent: Decimal; var IsHandled: Boolean): 

OnBeforeCalculateStatusExternalOrders(Code[20], Integer, Option, Decimal, Option, Decimal, Boolean) :

Summary: Fired before the external order signal calculation starts, allowing subscribers to skip the standard CalculateStatusExternalOrders logic entirely.

[IntegrationEvent(false, false)]
local procedure OnBeforeCalculateStatusExternalOrders(ProdOrderNo: Code[20]; ProdOrderLineNo: Integer; var SignalExternalOrders: Option; var ExternalOrdersInPercent: Decimal; var SignalExternalReply: Option; var ExternalReplyInPercentr: Decimal; var IsHandled: Boolean): 

Parameters:

  • ProdOrderNo: The production order number.
  • ProdOrderLineNo: The production order line number (0 = all lines).
  • SignalExternalOrders: Output: the external order creation signal to use if IsHandled = true.
  • ExternalOrdersInPercent: Output: the external order creation percentage to use if IsHandled = true.
  • SignalExternalReply: Output: the external reply signal to use if IsHandled = true.
  • ExternalReplyInPercentr: Output: the external reply percentage to use if IsHandled = true.
  • IsHandled: Set to true to skip the standard calculation code.

Remarks: Implements the IsHandled pattern: if a subscriber sets IsHandled = true, the standard subcontracting routing line loop and purchase/capacity evaluation are skipped entirely. All output parameters (signals and percentages) must then be populated by the subscriber.

OnBeforeCheckItemIsBlockedOnBeforeInsertProdOrderComponent(Record Prod. Order Component, Boolean) :

Summary: Fired before the blocked-item check in the Prod. Order Component OnBeforeInsert event, allowing subscribers to skip the standard KVSKBAIsBlockedManufConsumption check.

[IntegrationEvent(false, false)]
local procedure OnBeforeCheckItemIsBlockedOnBeforeInsertProdOrderComponent(var Rec: Record "Prod. Order Component"; var Handled: Boolean): 

Parameters:

  • Rec: The production order component being inserted.
  • Handled: Set to true to skip the standard item and item variant blocking checks.

Remarks: Raised inside the event subscriber for Prod. Order Component.OnBeforeInsert, before the item and item variant blocking checks are executed. If Handled = true, neither KVSKBAIsBlockedManufConsumption nor KVSKBAIsProdConsumpBlocked is called for the inserted component.

OnBeforeCheckItemIsBlockedOnValidateItemNoProdOrderComponent(Record Prod. Order Component, Record Prod. Order Component, Boolean) :

Summary: Fired before the blocked-item check when Item No. is validated on a Prod. Order Component, allowing subscribers to skip the standard KVSKBAIsBlockedManufConsumption check.

[IntegrationEvent(false, false)]
local procedure OnBeforeCheckItemIsBlockedOnValidateItemNoProdOrderComponent(var Rec: Record "Prod. Order Component"; var xRec: Record "Prod. Order Component"; var IsHandled: Boolean): 

Parameters:

  • Rec: The production order component being validated.
  • xRec: The previous state of the production order component.
  • IsHandled: Set to true to skip the standard item blocking check.

Remarks: Raised inside the event subscriber for Prod. Order Component.OnValidateItemNo, before the item blocking check is executed. If IsHandled = true, KVSKBAIsBlockedManufConsumption is not called for the validated component.

OnBeforeCheckItemIsBlockedOnValidateQuantityProdOrderComponent(Record Prod. Order Component, Record Prod. Order Component, Boolean) :

Summary: Fired before the blocked-item check when Quantity is validated on a Prod. Order Component, allowing subscribers to skip the standard KVSKBAIsBlockedManufConsumption check.

[IntegrationEvent(false, false)]
local procedure OnBeforeCheckItemIsBlockedOnValidateQuantityProdOrderComponent(var Rec: Record "Prod. Order Component"; var xRec: Record "Prod. Order Component"; var IsHandled: Boolean): 

Parameters:

  • Rec: The production order component being validated.
  • xRec: The previous state of the production order component.
  • IsHandled: Set to true to skip the standard item and item variant blocking checks.

Remarks: Raised inside the event subscriber for Prod. Order Component.OnValidateQuantity, before the item and item variant blocking checks are executed. If IsHandled = true, neither KVSKBAIsBlockedManufConsumption nor KVSKBAIsProdConsumpBlocked is called.

OnBeforeCheckItemIsBlockedOnValidateQuantityperProdOrderComponent(Record Prod. Order Component, Record Prod. Order Component, Boolean) :

Summary: Fired before the blocked-item check when Quantity per is validated on a Prod. Order Component, allowing subscribers to skip the standard KVSKBAIsBlockedManufConsumption check.

[IntegrationEvent(false, false)]
local procedure OnBeforeCheckItemIsBlockedOnValidateQuantityperProdOrderComponent(var Rec: Record "Prod. Order Component"; var xRec: Record "Prod. Order Component"; var IsHandled: Boolean): 

Parameters:

  • Rec: The production order component being validated.
  • xRec: The previous state of the production order component.
  • IsHandled: Set to true to skip the standard item and item variant blocking checks.

Remarks: Raised inside the event subscriber for Prod. Order Component.OnValidateQuantityPer, before the item and item variant blocking checks are executed. If IsHandled = true, neither KVSKBAIsBlockedManufConsumption nor KVSKBAIsProdConsumpBlocked is called.

OnCalculateStatusCapacityOnBeforeModifyCalcProdOrderRoutingLineOnIfTypeWorkCenter(Enum Production Order Status, Code[20], Integer, Record Prod. Order Routing Line, Record KVSKBACalcProdOrderRoutingLine) :

[IntegrationEvent(false, false)]
local procedure OnCalculateStatusCapacityOnBeforeModifyCalcProdOrderRoutingLineOnIfTypeWorkCenter(ProdOrderStatus: Enum "Production Order Status"; ProdOrderNo: Code[20]; ProdOrderLineNo: Integer; ProdOrderRoutingLine: Record "Prod. Order Routing Line"; var TempCalcProdOrderRoutingLine: Record "KVSKBACalcProdOrderRoutingLine" temporary): 

OnCalculateStatusCapacityOnBeforeInsertTempCalcProdOrderRoutingLineOnIfTypeWorkCenter(Enum Production Order Status, Code[20], Integer, Record Prod. Order Routing Line, Record KVSKBACalcProdOrderRoutingLine) :

[IntegrationEvent(false, false)]
local procedure OnCalculateStatusCapacityOnBeforeInsertTempCalcProdOrderRoutingLineOnIfTypeWorkCenter(ProdOrderStatus: Enum "Production Order Status"; ProdOrderNo: Code[20]; ProdOrderLineNo: Integer; ProdOrderRoutingLine: Record "Prod. Order Routing Line"; var TempCalcProdOrderRoutingLine: Record "KVSKBACalcProdOrderRoutingLine" temporary): 

OnCalculateStatusCapacityOnBeforeModifyTempCalcProdOrderRoutingLineOnIfTypeMachineCenter(Enum Production Order Status, Code[20], Integer, Record Prod. Order Routing Line, Record KVSKBACalcProdOrderRoutingLine) :

[IntegrationEvent(false, false)]
local procedure OnCalculateStatusCapacityOnBeforeModifyTempCalcProdOrderRoutingLineOnIfTypeMachineCenter(ProdOrderStatus: Enum "Production Order Status"; ProdOrderNo: Code[20]; ProdOrderLineNo: Integer; ProdOrderRoutingLine: Record "Prod. Order Routing Line"; var TempCalcProdOrderRoutingLine: Record "KVSKBACalcProdOrderRoutingLine" temporary): 

OnCalculateStatusCapacityOnBeforeInsertTempCalcProdOrderRoutingLineOnIfTypeMachineCenter(Enum Production Order Status, Code[20], Integer, Record Prod. Order Routing Line, Record KVSKBACalcProdOrderRoutingLine) :

[IntegrationEvent(false, false)]
local procedure OnCalculateStatusCapacityOnBeforeInsertTempCalcProdOrderRoutingLineOnIfTypeMachineCenter(ProdOrderStatus: Enum "Production Order Status"; ProdOrderNo: Code[20]; ProdOrderLineNo: Integer; ProdOrderRoutingLine: Record "Prod. Order Routing Line"; var TempCalcProdOrderRoutingLine: Record "KVSKBACalcProdOrderRoutingLine" temporary): 

OnCalculateStatusCapacityOnBeforeModifyTempCalcProdOrderRoutingLineOnCapacityEntry(Record KVSKBACalcProdOrderRoutingLine, Record Capacity Ledger Entry) :

Summary: Fired before the temporary calc routing line record is modified after summing capacity ledger entries for a work/machine center in CalculateStatusCapacity.

[IntegrationEvent(false, false)]
local procedure OnCalculateStatusCapacityOnBeforeModifyTempCalcProdOrderRoutingLineOnCapacityEntry(var TempCalcProdOrderRoutingLine: Record "KVSKBACalcProdOrderRoutingLine" temporary; CapacityLedgerEntry: Record "Capacity Ledger Entry"): 

Parameters:

  • TempCalcProdOrderRoutingLine: The temporary routing line record accumulating posted time and output for the current work/machine center. Modify fields here before the standard Modify call.
  • CapacityLedgerEntry: The capacity ledger entry record filtered to the current routing line (sums already calculated via CalcSums).

Remarks: Fired after CalcSums has been called on the CapacityLedgerEntry for the current work/machine center, immediately before TempCalcProdOrderRoutingLine is updated with the summed actual time and output values. Use a subscriber to override the calculated sums or add corrections before the Modify call.

OnCalculateStatusCapacityOnAfterSetSignalLabour(Record KVSKBACalcProdOrderRoutingLine, Decimal, Decimal, Decimal, Decimal, Option, Decimal, Option, Decimal) :

Summary: Fired after the labor consumption and output reply signals and percentages have been determined from the accumulated routing line data in CalculateStatusCapacity, allowing subscribers to override the final signal values.

[IntegrationEvent(false, false)]
local procedure OnCalculateStatusCapacityOnAfterSetSignalLabour(var TempCalcProdOrderRoutingLine: Record "KVSKBACalcProdOrderRoutingLine" temporary; CalculatedLaborQty: Decimal; ConsumedLaborQty: Decimal; CalculatedOutputQty: Decimal; PostedOutputQty: Decimal; var SignalLaborConsum: Option; var LaborConsumInPercent: Decimal; var SignalLaborOutput: Option; var LaborOutputInPercent: Decimal): 

Parameters:

  • TempCalcProdOrderRoutingLine: The last-processed temporary routing line record (positioned at the end of the loop).
  • CalculatedLaborQty: The total planned labor time (sum of Total Calc. Time Per Work across all routing lines).
  • ConsumedLaborQty: The total actual time used (sum of Total Used Time Per Work across all routing lines).
  • CalculatedOutputQty: The total planned output quantity (sum of Total Qty. Per Work across all routing lines).
  • PostedOutputQty: The total posted output quantity (sum of Total Output Qty. Per Work across all routing lines).
  • SignalLaborConsum: The labor consumption signal. Can be overridden.
  • LaborConsumInPercent: The labor consumption percentage. Can be overridden.
  • SignalLaborOutput: The output reply signal. Can be overridden.
  • LaborOutputInPercent: The output reply percentage. Can be overridden.

Remarks: Fired after CalculateStatusCapacity has compared planned vs. actual totals and assigned the signal color thresholds. All four quantity parameters are passed by value (read-only); signal and percentage parameters are passed by reference and can be freely overridden.

OnAfterClearCalcProdOrderRoutingLine(Record KVSKBACalcProdOrderRoutingLine) :

Summary: Fired after the accumulation fields of a temporary calc routing line record have been cleared (reset to 0) in preparation for a new work/machine center entry.

[IntegrationEvent(false, false)]
local procedure OnAfterClearCalcProdOrderRoutingLine(var TempCalcProdOrderRoutingLine: Record "KVSKBACalcProdOrderRoutingLine" temporary): 

Parameters:

  • TempCalcProdOrderRoutingLine: The temporary routing line record whose accumulation fields were just reset. Set additional fields to zero or default here if needed.

Remarks: Fired in the local procedure ClearCalcProdOrderRoutingLine, which is called each time the accumulation pointer moves to a new work/machine center group. Use a subscriber to reset any custom fields added to the KVSKBACalcProdOrderRoutingLine table.