You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please add an event OnBeforeCheckAvailability in the procedure CalcAvailability in Codeunit 5870 "Calculate BOM Tree"
local procedure CalcAvailability(var BOMBuffer: Record "BOM Buffer"; Input: Decimal; IsTest: Boolean): Boolean
var
ParentBOMBuffer: Record "BOM Buffer";
ExpectedQty: Decimal;
AvailQty: Decimal;
MaxTime: Integer;
IsHandled: Boolean;
begin
if BOMBuffer.Indentation = 0 then begin
if IsTest then
if TempMemoizedResult.Get(Input) then
exit(TempMemoizedResult.Output);
ResetUpdatedAvailability();
end;
MaxTime := 0;
ParentBOMBuffer := BOMBuffer;
while (BOMBuffer.Next() <> 0) and (ParentBOMBuffer.Indentation < BOMBuffer.Indentation) do
if ParentBOMBuffer.Indentation + 1 = BOMBuffer.Indentation then begin
TempItemAvailByDate.SetRange("Item No.", BOMBuffer."No.");
TempItemAvailByDate.SetRange(Date, BOMBuffer."Needed by Date");
TempItemAvailByDate.SetRange("Variant Code", BOMBuffer."Variant Code");
if LocationSpecific then
TempItemAvailByDate.SetRange("Location Code", BOMBuffer."Location Code");
TempItemAvailByDate.FindFirst();
if BOMBuffer."Calculation Formula" = BOMBuffer."Calculation Formula"::"Fixed Quantity" then begin
ExpectedQty := Round(BOMBuffer."Qty. per Parent", UOMMgt.QtyRndPrecision());
AvailQty := TempItemAvailByDate."Available Qty"
end
else begin
ExpectedQty := Round(BOMBuffer."Qty. per Parent" * Input, UOMMgt.QtyRndPrecision());
AvailQty := TempItemAvailByDate."Updated Available Qty";
end;
OnBeforeCheckAvailability(BOMBuffer, AvailQty, ExpectedQty, IsHandled); // <--- New Event
if IsHandled then
exit;
if AvailQty < ExpectedQty then begin // <---- This needs to be AvailQty <= ExpectedQty
if BOMBuffer."Is Leaf" then begin
if MarkBottleneck then begin
BOMBuffer.Bottleneck := true;
BOMBuffer.Modify(true);
end;
BOMBuffer := ParentBOMBuffer;
if (BOMBuffer.Indentation = 0) and IsTest then
AddMemoizedResult(Input, false);
exit(false);
end;
if AvailQty <> 0 then
ReduceAvailability(BOMBuffer."No.", BOMBuffer."Variant Code", BOMBuffer."Location Code", BOMBuffer."Needed by Date", AvailQty, BOMBuffer."Calculation Formula");
if not IsTest then begin
BOMBuffer."Available Quantity" := AvailQty;
BOMBuffer.Modify();
end;
if not CalcAvailability(BOMBuffer, ExpectedQty - AvailQty, IsTest) then begin
if MarkBottleneck then begin
BOMBuffer.Bottleneck := true;
BOMBuffer.Modify(true);
end;
BOMBuffer := ParentBOMBuffer;
if (BOMBuffer.Indentation = 0) and IsTest then
AddMemoizedResult(Input, false);
exit(false);
end;
if not IsTest then
if MaxTime < (ParentBOMBuffer."Needed by Date" - BOMBuffer."Needed by Date") + BOMBuffer."Rolled-up Lead-Time Offset" then
MaxTime := (ParentBOMBuffer."Needed by Date" - BOMBuffer."Needed by Date") + BOMBuffer."Rolled-up Lead-Time Offset";
end else begin
if not IsTest then begin
if BOMBuffer."Calculation Formula" <> BOMBuffer."Calculation Formula"::"Fixed Quantity" then begin
BOMBuffer."Available Quantity" := ExpectedQty;
BOMBuffer.Modify();
end;
if MaxTime < (ParentBOMBuffer."Needed by Date" - BOMBuffer."Needed by Date") + BOMBuffer."Rolled-up Lead-Time Offset" then
MaxTime := (ParentBOMBuffer."Needed by Date" - BOMBuffer."Needed by Date") + BOMBuffer."Rolled-up Lead-Time Offset";
end;
ReduceAvailability(BOMBuffer."No.", BOMBuffer."Variant Code", BOMBuffer."Location Code", BOMBuffer."Needed by Date", ExpectedQty, BOMBuffer."Calculation Formula");
end;
end;
BOMBuffer := ParentBOMBuffer;
BOMBuffer."Rolled-up Lead-Time Offset" := MaxTime;
BOMBuffer.Modify(true);
if (BOMBuffer.Indentation = 0) and IsTest then
AddMemoizedResult(Input, true);
exit(true);
end;
[IntegrationEvent(false, false)]
local procedure OnBeforeCheckAvailability(var BOMBuffer: Record "BOM Buffer"; var AvailQty: Decimal; var ExpectedQty: Decimal; var IsHandled: Boolean)
begin
end;
Additional context
We need to replace the base logic if AvailQty < ExpectedQty with our custom logic if AvailQty <= ExpectedQty at line No. 802 in the procedure CalcAvailability.
The text was updated successfully, but these errors were encountered:
Describe the request
Please add an event OnBeforeCheckAvailability in the procedure CalcAvailability in Codeunit 5870 "Calculate BOM Tree"
Additional context
We need to replace the base logic
if AvailQty < ExpectedQty
with our custom logicif AvailQty <= ExpectedQty
at line No. 802 in the procedure CalcAvailability.The text was updated successfully, but these errors were encountered: