...
SetItemLedgEntryFilters(ItemLedgEntry,StartingDate,ReferenceDate,'%1',ItemLedgEntry."Entry Type"::Purchase);
IF ItemLedgEntry.FINDSET THEN
REPEAT
// Delete the following lines.
ItemLedgEntry.CALCFIELDS("Cost Amount (Expected)","Cost Amount (Actual)");
IF ItemLedgEntry."Cost Amount (Actual)" <> 0 THEN
ItemCostHistory."Purchase Amount" += ItemLedgEntry."Cost Amount (Actual)"
ELSE
ItemCostHistory."Purchase Amount" += ItemLedgEntry."Cost Amount (Expected)";
// End of the lines.
ItemCostHistory."Purchase Quantity" += ItemLedgEntry.Quantity;
UNTIL ItemLedgEntry.NEXT = 0;
END;
...
...
SetItemLedgEntryFilters(ItemLedgEntry,StartingDate,ReferenceDate,'%1',ItemLedgEntry."Entry Type"::Purchase);
IF ItemLedgEntry.FINDSET THEN
REPEAT
// Add the following lines.
ItemLedgEntry.CALCFIELDS("Purchase Amount (Expected)","Purchase Amount (Actual)");
IF ItemLedgEntry."Purchase Amount (Actual)" <> 0 THEN
ItemCostHistory."Purchase Amount" += ItemLedgEntry."Purchase Amount (Actual)"
ELSE
ItemCostHistory."Purchase Amount" += ItemLedgEntry."Purchase Amount (Expected)";
// End of the lines.
ItemCostHistory."Purchase Quantity" += ItemLedgEntry.Quantity;
UNTIL ItemLedgEntry.NEXT = 0;
END;
...