ALAppExtensions icon indicating copy to clipboard operation
ALAppExtensions copied to clipboard

[Event Request] Codeunit 5870 - Calculate BOM Tree

Open IngoStender opened this issue 7 years ago • 2 comments

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')

IngoStender avatar Aug 08 '19 10:08 IngoStender

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?

NKarolak avatar Sep 02 '19 12:09 NKarolak

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));
              [...]

IngoStender avatar Sep 03 '19 09:09 IngoStender