LOCAL FindPurchPrice(VAR ToPurchPrice : Record "Purchase Price";VendorNo : Code[20];ItemNo : Code[20];VariantCode : Code[10];UOM : Code[10];CurrencyCode : Code[10];StartingDate : Date;ShowAll : Boolean)
WITH FromPurchPrice DO BEGIN
SETRANGE("Item No.",ItemNo);
SETRANGE("Purchase Type", "Purchase Type"::Vendor);
SETRANGE("Purchase Code",VendorNo);
SETFILTER("Ending Date",'%1|>=%2',0D,StartingDate);
SETFILTER("Variant Code",'%1|%2',VariantCode,'');
IF NOT ShowAll THEN BEGIN
SETRANGE("Starting Date",0D,StartingDate);
SETFILTER("Currency Code",'%1|%2',CurrencyCode,'');
SETFILTER("Unit of Measure Code",'%1|%2',UOM,'');
END;
ToPurchPrice.RESET;
ToPurchPrice.DELETEALL;
IF FIND('-') THEN
REPEAT
IF "Direct Unit Cost" <> 0 THEN BEGIN //this code
ToPurchPrice := FromPurchPrice;
ToPurchPrice.INSERT;
END;
UNTIL NEXT = 0;
SETRANGE("Purchase Type", "Purchase Type"::"Vendor Price Group");
SETRANGE("Purchase Code", Vend."Vendor Price Group Code");
IF FromPurchPrice.FIND('-') THEN BEGIN
REPEAT
IF FromPurchPrice."Direct Unit Cost" <> 0 THEN BEGIN //this code
ToPurchPrice := FromPurchPrice;
ToPurchPrice.INSERT;
END;
UNTIL FromPurchPrice.NEXT = 0;
END;
END;