![]() |
#7 |
Участник
|
Вот как мне кажется должно все выглядеть:
Тезрают сомнение: 1) EXIT; а отчете он пишется как CurrReport.BREAK; Код: WHILE BomComponent[Level].NEXT = 0 DO BEGIN Level := Level - 1; IF Level < 1 THEN EXIT; IF NOT UpperLevelItem.GET(NoList[Level]) THEN UpperLevelItem."Production BOM No." := NoList[Level]; BomComponent[Level].SETRANGE("Production BOM No.",UpperLevelItem."Production BOM No."); BomComponent[Level].SETRANGE("Version Code",VersionCode[Level]); END; во втором и третьем датаитеме: IF BomComponent[Level].FIND('-') THEN REPEAT 3) Выдается ошибка: Индекс массива 0 за пределами допустимого интервала.... мне кажется что это BomComponent[Level] Код: ItemPresents.COPY(Rec); IF ItemPresents.FIND('-') THEN REPEAT ItemPresents.SETFILTER("Production BOM No.",'<>%1',''); Level := 1; ProdBOM.GET(ItemPresents."Production BOM No."); VersionCode[Level] := VersionMgt.GetBOMVersion(ItemPresents."Production BOM No.","Calc.Date",FALSE); CLEAR(BomComponent); BomComponent[Level]."Production BOM No." := ItemPresents."Production BOM No."; BomComponent[Level].SETRANGE("Production BOM No.",ItemPresents."Production BOM No."); BomComponent[Level].SETRANGE("Version Code",VersionCode[Level]); BomComponent[Level].SETFILTER("Starting Date",'%1|..%2',0D,"Calc.Date"); BomComponent[Level].SETFILTER("Ending Date",'%1|%2..',0D,"Calc.Date"); NoList[Level] := ItemPresents."No."; Quantity[Level] := UOMMgt.GetQtyPerUnitOfMeasure(ItemPresents,ItemPresents."Base Unit of Measure") / UOMMgt.GetQtyPerUnitOfMeasure( ItemPresents, VersionMgt.GetBOMUnitOfMeasure( ItemPresents."Production BOM No.",VersionCode[Level])); UpperLevelItem := ItemPresents; IF BomComponent[Level].FIND('-') THEN REPEAT WHILE BomComponent[Level].NEXT = 0 DO BEGIN Level := Level - 1; IF Level < 1 THEN EXIT; IF NOT UpperLevelItem.GET(NoList[Level]) THEN UpperLevelItem."Production BOM No." := NoList[Level]; BomComponent[Level].SETRANGE("Production BOM No.",UpperLevelItem."Production BOM No."); BomComponent[Level].SETRANGE("Version Code",VersionCode[Level]); END; NextLevel := Level; CLEAR(CompItem); QtyPerUnitOfMeasure := 1; CASE BomComponent[Level].Type OF BomComponent[Level].Type::Item: BEGIN CompItem.GET(BomComponent[Level]."No."); IF CompItem."Production BOM No." <> '' THEN BEGIN NextLevel := Level + 1; CLEAR(BomComponent[NextLevel]); NoList[NextLevel] := CompItem."No."; VersionCode[NextLevel] := VersionMgt.GetBOMVersion(CompItem."Production BOM No.","Calc.Date",FALSE); BomComponent[NextLevel].SETRANGE("Production BOM No.",CompItem."Production BOM No."); BomComponent[NextLevel].SETRANGE("Version Code",VersionCode[NextLevel]); BomComponent[NextLevel].SETFILTER("Starting Date",'%1|..%2',0D,"Calc.Date"); BomComponent[NextLevel].SETFILTER("Ending Date",'%1|%2..',0D,"Calc.Date"); QtyPerUnitOfMeasure := UOMMgt.GetQtyPerUnitOfMeasure( ItemPresents, ItemPresents."Base Unit of Measure") / UOMMgt.GetQtyPerUnitOfMeasure( CompItem, VersionMgt.GetBOMUnitOfMeasure( CompItem."Production BOM No.",VersionCode[NextLevel])); END; IF Level > 1 THEN BEGIN IF BomItem.GET(BomComponent[Level - 1]."No.") THEN BEGIN QtyPerUnitOfMeasure := UOMMgt.GetQtyPerUnitOfMeasure(BomItem,BomComponent[Level - 1]."Unit of Measure Code") / UOMMgt.GetQtyPerUnitOfMeasure( BomItem,VersionMgt.GetBOMUnitOfMeasure(BomItem."Production BOM No.",VersionCode[Level])); END; END; END; BomComponent[Level].Type::"Production BOM": BEGIN ProdBOM.GET(BomComponent[Level]."No."); NextLevel := Level + 1; CLEAR(BomComponent[NextLevel]); NoList[NextLevel] := ProdBOM."No."; VersionCode[NextLevel] := VersionMgt.GetBOMVersion(ProdBOM."No.","Calc.Date",FALSE); BomComponent[NextLevel].SETRANGE("Production BOM No.",NoList[NextLevel]); BomComponent[NextLevel].SETRANGE("Version Code",VersionCode[NextLevel]); BomComponent[NextLevel].SETFILTER("Starting Date",'%1|..%2',0D,"Calc.Date"); BomComponent[NextLevel].SETFILTER("Ending Date",'%1|%2..',0D,"Calc.Date"); END; END; IF NextLevel <> Level THEN Quantity[NextLevel] := BomComponent[NextLevel - 1].Quantity * QtyPerUnitOfMeasure * Quantity[Level]; IF BomComponent[Level].FIND('-') THEN REPEAT BOMQty := Quantity[Level] * QtyPerUnitOfMeasure * BomComponent[Level].Quantity; UNTIL BomComponent[Level].NEXT =0; Level := NextLevel; IF CompItem."Production BOM No." <> '' THEN UpperLevelItem := CompItem; UNTIL BomComponent[Level].NEXT =0; UNTIL ItemPresents.NEXT =0; |
|