LOCAL CalcPhysInvQtyAndInsertItemJnlLine() // ++++++++++++++ start new code #1 QuantityOnHandBuffer.RESET; IF NOT ZeroQty THEN // user input QuantityOnHandBuffer.SETFILTER(Quantity, '<>0'); // get all items, which have been processed by the report before // this will also respect any given filter by the user on the RequestPage // ItemBuffer is a temporary variable IF QuantityOnHandBuffer.FINDSET THEN REPEAT IF NOT ItemBuffer.GET(QuantityOnHandBuffer."Item No.") THEN BEGIN ItemBuffer.INIT; ItemBuffer."No." := QuantityOnHandBuffer."Item No."; ItemBuffer.INSERT; END; UNTIL QuantityOnHandBuffer.NEXT = 0; // now randomize MaxStepsPossible := ItemBuffer.COUNT; MaxItems := 10; // this could be a new option on the RequestPage FOR i := 1 TO MaxItems DO BEGIN ItemBuffer.FINDFIRST; // always start from first record ItemBuffer.NEXT(RANDOM(MaxStepsPossible)); ItemBuffer.MARK(TRUE); END; // ---------------- end new code #1 WITH QuantityOnHandBuffer DO BEGIN RESET; // ++++++++++++++ start new code #2 // loop through my randomized result of the items which have been processed by the report ItemBuffer.MARKEDONLY(TRUE); IF ItemBuffer.FINDSET THEN REPEAT SETRANGE("Item No.", ItemBuffer."No."); IF FINDSET THEN REPEAT MARK(TRUE); // mark the corresponding records in the QuantityOnHandBuffer UNTIL NEXT = 0; UNTIL ItemBuffer.NEXT = 0; SETRANGE("Item No."); MARKEDONLY(TRUE); // ---------------- end new code #2 IF FINDSET THEN BEGIN REPEAT PosQty := 0; NegQty := 0;
Answers
At any rate, NAV has cycle counting, and if you look at the Item Card, Warehouse tab, there are fields like next counting period start, end etc. date. This is uneditable and normally written automatically. Make it editable and play with it. If you set two products to be counted next week, does it work, does it take them into accounting when running it?
Suppose that works. If they insist on randomness you will probably need to write code that when an inventory list is generated, or when the inventory is posted, the next counting period of these items is bumped up into next year. And another code that that as a batch job updates the ones that are in this year randomly.
This really looks like an ugly thing. Just convince them to use rolling counting
Now my purpose on Report 790 is to limit the function , to my random items?
...
Item - OnPostDataItem()
CalcPhysInvQtyAndInsertItemJnlLine;
...
Thanks for the tips!!
Thanks a lot!