Navision Bug, or my Progamming Error?

elToritoelTorito Member Posts: 191
Hi,

I Have trouble with some Function i have programmed. Perhaps you can help me.

With Transfer Orders we put Items in an Inventory, are Items that we can not Sale, because are broken or what ever, after check the items, this Inventory must be put to 0. So we do it with an Item Journal, for clean the Inventory.

Now i have programmed some function for fill the Item Journal, that we only must book it out, but it seems that my function doesn't fill the field Quantity (Base) , so it exists an Item Ledger Entry with Quantity 0 but an Value Not Zero. So i have Inventory Quantity with 1.
Then i fill Item Journal Line manually with Quantity 1 and Value 0. After this, Quantity in inventory was 0, but i don#t know that makes the adjust cost - item entrys, because after run Report 1001 i have quantity -1 and cost posted to G/L are negative.

I find it curiosly that Navision book the Lines with Quantity Base = 0

Well, perhaps anyone can say me how i cann correct my function so it fills Quantity(base) Correctly, Thanks:
  ItemLedgerEntry.SETFILTER("Location Code", 'EXIT_INVENTORY');
  ItemLedgerEntry.SETFILTER(Open, 'Ja');
  IF ItemLedgerEntry.FIND('-') THEN REPEAT
  ZL += 10000;
  ItemJournalLine.INIT;
  ItemJournalLine."Journal Template Name" := 'ITEM';
  ItemJournalLine."Journal Batch Name" := 'BOOK_OUT';
  ItemJournalLine."Line No." := ZL;
  ItemJournalLine.INSERT;
  ItemJournalLine."Document No." := 'DocNo';
  ItemJournalLine.VALIDATE("Posting Date",ItemLedgerEntry."Posting Date");
  ItemJournalLine.VALIDATE("Entry Type",ItemLedgerEntry."Entry Type");
  ItemJournalLine.VALIDATE("Item No.",ItemLedgerEntry."Item No.");
  ItemJournalLine.VALIDATE("Location Code",'EXIT_INVENTORY');
  ItemJournalLine.VALIDATE("Variant Code",ItemLedgerEntry."Variant Code");
  ItemJournalLine.VALIDATE("Entry Type",3);

  ItemJournalLine.VALIDATE(Quantity,ItemLedgerEntry."Quantity (Base)");
  ItemJournalLine.VALIDATE("Quantity (Base)",ItemLedgerEntry."Quantity (Base)");
  ItemJournalLine.VALIDATE("Applies-to Entry",ItemLedgerEntry."Entry No.");
  ItemJournalLine.MODIFY;
  UNTIL ItemLedgerEntry.NEXT=0;
:shock:
(Oo)=*=(oO)

Comments

  • KowaKowa Member Posts: 925
    If you validate the "Unit of Measure Code", it should be sufficient to validate the Quantity. The "Quantity ( Base)" is calculated by the function CalcBaseQty in the Item Journal line if the "Qty. per Unit of Measure" is known.
    Kai Kowalewski
  • elToritoelTorito Member Posts: 191
    Kowa wrote:
    If you validate the "Unit of Measure Code", it should be sufficient to validate the Quantity. The "Quantity ( Base)" is calculated by the function CalcBaseQty in the Item Journal line if the "Qty. per Unit of Measure" is known.

    Yes, i have try to intend this, only filling quantity, but doesn't work. Quantity(base) believes 0. And seems that Navision don't check it before booking the lines.
    (Oo)=*=(oO)
  • ara3nara3n Member Posts: 9,257
    The code on item journal for quantity (base) get calculated here
    CalcBaseQty(Qty : Decimal) : Decimal
    TESTFIELD("Qty. per Unit of Measure");
    EXIT(ROUND(Qty * "Qty. per Unit of Measure",0.00001));
    


    So you should get an error when you validate quantity field.

    The code onvalidate of quantity field is
    Quantity - OnValidate()
    ....code
    "Quantity (Base)" := CalcBaseQty(Quantity);
    ..code
    
    
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
Sign In or Register to comment.