ALAppExtensions
ALAppExtensions copied to clipboard
[Event Request] Codeunit 5870 - Calculate BOM Tree
In codeunit 5870 Calculate BOM Tree, function GenerateProdCompSubTree, please add the following event and related code change.
For a specific functions of our solution, the quantity per in a production BOM line can be 0 and is only calculated when the production BOM line is used, considering additional values and relations.
WITH ProdBOMLine DO BEGIN
SETRANGE("Production BOM No.",ParentItem."Production BOM No.");
SETRANGE("Version Code",VersionMgt.GetBOMVersion(ParentItem."Production BOM No.",WORKDATE,TRUE));
SETFILTER("Starting Date",'%1|..%2',0D,ParentBOMBuffer."Needed by Date");
SETFILTER("Ending Date",'%1|%2..',0D,ParentBOMBuffer."Needed by Date");
// >> ----DELETE
// SETFILTER("Quantity per",'>%1',0);
// << ----DELETE
IF FINDSET THEN BEGIN
IF ParentItem."Replenishment System" <> ParentItem."Replenishment System"::"Prod. Order" THEN
EXIT(TRUE);
REPEAT
// >> ----NEW
OnBeforeTransferProdBOMLine(BOMBuffer,ProdBOMLine,ParentItem,ParentBOMBuffer,EntryNo,TreeType);
IF "Quantity per" > 0 THEN BEGIN
// << ----NEW
IF "No." <> '' THEN
CASE Type OF
[...]
END;
// >> ----NEW
END;
// << ----NEW
UNTIL NEXT = 0;
FoundSubTree := TRUE;
END;
END;
text
LOCAL [IntegrationEvent] OnBeforeTransferProdBOMLine(VAR BOMBuffer : Record "BOM Buffer";VAR ProdBOMLine : Record "Production BOM Line";VAR ParentItem : Record Item;VAR ParentBOMBuffer : Record "BOM Buffer";VAR EntryNo : Integer;TreeType : ' ,Availability,Cost')
Note: implemented in BC Insider as
[…]
WITH ProdBOMLine DO BEGIN
SETRANGE("Production BOM No.",ParentItem."Production BOM No.");
SETRANGE("Version Code",VersionMgt.GetBOMVersion(ParentItem."Production BOM No.",WORKDATE,TRUE));
SETFILTER("Starting Date",'%1|..%2',0D,ParentBOMBuffer."Needed by Date");
SETFILTER("Ending Date",'%1|%2..',0D,ParentBOMBuffer."Needed by Date");
IsHandled := FALSE;
OnBeforeFilterByQuantityPer(ProdBOMLine,IsHandled);
IF NOT IsHandled THEN
SETFILTER("Quantity per",'>%1',0);
IF FINDSET THEN BEGIN
[…]
(no change after REPEAT)
@IngoStender Does that changed version work for you anyway?
No. This works only with an additional event in case type item as it already exists in the case type production BOM as OnBeforeTransferFromProdBOM()
[...]
IF "No." <> '' THEN
CASE Type OF
Type::Item:
BEGIN
// >> New
OnBeforeTransferFromItem(BOMBuffer,ProdBOMLine,ParentItem,ParentBOMBuffer,EntryNo,TreeType);
// << New
BOMBuffer.SetLocationVariantFiltersFrom(ItemFilter);
BomQtyPerUom :=
GetQtyPerBOMHeaderUnitOfMeasure(
ParentItem,ParentBOMBuffer."Production BOM No.",
VersionMgt.GetBOMVersion(ParentBOMBuffer."Production BOM No.",WORKDATE,TRUE));
[...]