Stop Updating Last Direct Cost on item card from Positive entries

Hi Experts ,

One of the cases that makes last direct cost updates in Item card from system; Is when we do positive entry from Item Journal line;

We need to stop updating the Last direct cost that comes from positive entries .

I went to code unit 22 -----> to UpdateUnitCost(ValueEntry : Record “Value Entry”) → and put comment down on the yellow color if the entry type is in Positive Adjmt -------> is this enough ? As i tried and test it worked fine but i need to know your comments or warnings about this change … thank you

CODEUNIT 22

UpdateUnitCost(ValueEntry : Record “Value Entry”)

WITH ValueEntry DO BEGIN

IF (“Valued Quantity” > 0) AND NOT (“Expected Cost” OR ItemJnlLine.Adjustment) THEN BEGIN

Item.LOCKTABLE;

IF NOT Item.FIND THEN

EXIT;

IF (“Item Ledger Entry Type” IN

[“Item Ledger Entry Type”::Purchase,

// “Item Ledger Entry Type”::“Positive Adjmt.”,

“Item Ledger Entry Type”::Output]) AND

(“Cost Amount (Actual)” + “Discount Amount” > 0) AND

(ItemJnlLine.“Value Entry Type” = ItemJnlLine.“Value Entry Type”::“Direct Cost”) AND

(ItemJnlLine.“Item Charge No.” = ‘’) AND

(“Invoiced Quantity” > 0)

THEN

Hi,

Last direct cost is basically a default purchase price so I don’t see any problem in your change if your not worried with the price of the item journal

I don’t think commenting out the code will have an effect.

Main reason because the code below runs regardless

ItemCostMgt.SetProperties(FALSE,“Invoiced Quantity”);

ItemCostMgt.UpdateUnitCost(Item,“Location Code”,“Variant Code”,LastDirectCost,0,TRUE,TRUE,FALSE,0);

I suggest to add an if statement around the statement

ItemCostMgt.SetProperties(FALSE,“Invoiced Quantity”);

ItemCostMgt.UpdateUnitCost(Item,“Location Code”,“Variant Code”,LastDirectCost,0,TRUE,TRUE,FALSE,0);

END;

I would test it and make sure it works.

thx Rashesd and Dave T .

Rashed i will be waiting for your testing .

…thx again for you concern

Hi Rashed again ,

I didn’t put IF Statement because i consider it; like negative adjustmennt where no condition for it in /// → If Item LEdger entry :IN Negative Adjmt

And at the same time no IF Statement before ///—>ItemCostMgt.UpdateUnitCost(Item,“Location Code”,“Variant Code”,LastDirectCost,0,TRUE,TRUE,FALSE,0);

where i supposed the lastdirect will go as Zero

after it will call code unit 5804 -----> Procedure updateUnitCost ------> where the Last direct cost = 0 ;

END ELSE BEGIN

IF (“Unit Cost” = 0) OR ((InvoicedQty > 0) AND (LastDirectCost <> 0)) THEN BEGIN

CALCFIELDS(“Net Invoiced Qty.”);

IF (“Net Invoiced Qty.” > 0) AND (“Net Invoiced Qty.” <= InvoicedQty) THEN BEGIN

“Unit Cost” := LastDirectCost;

CalcItemCostACY(Item); //Meg03.00

END;

END;

END;

END;

IF RecalcStdCost THEN

RecalcStdCostItem(Item);

IF LastDirectCost <> 0 THEN BEGIN

"Last Direct Cost" := LastDirectCost

Please Rashed if i am wrong correct me … And please tell me if i need still too put IF statemnet … For me it 's first time to update in such coding in navision

thx again for your concern AND ATTENTION

Adding the if statement will make the code to run a little faster, I think if you test it and it doesn’t change the cost, then you should be set.

thanks Rashed for all you help … i implemented and till now everything is working properly