Adjust Cost - Item Entries for one Item or all others

abartonicekabartonicek Member Posts: 162
edited 2006-04-25 in Navision Attain
We all know that this batch is very tricky so I wanted to modify it so I can run it for:
a) particular Item (infinite loop is killing me)
b) all Items except that one

With big help from "Guidelines for Loops in Adjust Cost Batch Job" document I solved a) case but I can't make b) case to work (or work properly) :cry:

I would appreciate some help. I searched the forum and I saw that somebody already done this...
Better to be critical then self-critical :)

Comments

  • kinekine Member Posts: 12,562
    Version of DB?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • kinekine Member Posts: 12,562
    For me the B is just negation of A... if you in A are using something like
    SETRANGE("Item No.",'myitem');
    
    than for B must work
    SETFILTER("Item No.",'<>%1','myitem');
    
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • abartonicekabartonicek Member Posts: 162
    I thought so too but....
    For a) case "Guidelines for Loops in Adjust Cost Batch Job" document says:
    LOCAL PROCEDURE MakeSingleLevelAdjmt (CU5895)
    ...
          ItemLedgEntry.SETCURRENTKEY("Item No.");
          ItemLedgEntry.SETRANGE("Item No.",'70000’);  //add line, filter on the item no. 
          IF NOT ItemLedgEntry.FIND('-') THEN  // that should be adjusted
            EXIT(FALSE);
    ...
            ItemLedgEntry.FIND('+');
           ItemLedgEntry.SETRANGE("Item No.");         // disable this line
          UNTIL (ItemLedgEntry.NEXT = 0) OR LevelExceeded
    

    For b) case I thought I should uncomment the
    //        ItemLedgEntry.SETRANGE("Item No.");
    
    line but the batch worked as I didn't set any filter.
    I tried with that line commented too, but the result was the same.
    Better to be critical then self-critical :)
  • abartonicekabartonicek Member Posts: 162
    I forgot, DB is 3.60.
    Better to be critical then self-critical :)
  • jreynoldsjreynolds Member Posts: 175
    Try using a different filter group when you set your filter on item number.
    LOCAL PROCEDURE MakeSingleLevelAdjmt (CU5895) 
    ... 
          ItemLedgEntry.SETCURRENTKEY("Item No."); 
          ItemLedgEntry.FILTERGROUP(9);
          ItemLedgEntry.SETRANGE("Item No.",'70000’);  //add line, filter on the item no. 
          ItemLedgEntry.FILTERGROUP(0);
    
          IF NOT ItemLedgEntry.FIND('-') THEN  // that should be adjusted 
            EXIT(FALSE); 
    ... 
            ItemLedgEntry.FIND('+'); 
           ItemLedgEntry.SETRANGE("Item No.");         // DO NOT DISABLE THIS LINE
          UNTIL (ItemLedgEntry.NEXT = 0) OR LevelExceeded
    
  • abartonicekabartonicek Member Posts: 162
    Didn't help :(

    All this is because infinite loop problem!

    The thing is, when I set that "Item No." filter the Adjust Cost - ... batch runs only for that item and it runs forever (inf. loop problem).

    When I try to use that <>Item No. filter ( b) case) to adjust all other items, the Adjust Cost - ... batch runs for a 0,5 sec and FIXES :?: the infinite loop problem so the Adjust Cost - ... batch for all Items runs normally (it takes some time)!!!

    I don't know what happens in that b) case but I checked and it seems that no adjustments have been maid in that batch run :?:
    The batch for all items adjusts all items except the one that created inf. loop problem :!:
    I confused :-k
    Any ideas?
    Better to be critical then self-critical :)
  • kinekine Member Posts: 12,562
    It FIXES the problem because the table 5804 Average Cost Adjustment is empty after you finis the batch and new run of the batch has nothing to adjust... you need to recovery the record for your item in this table...
    (but this is without warranty...)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • abartonicekabartonicek Member Posts: 162
    I forgot about that T5804 #-o . Thanks for heads-up!

    Maybe stupid question but why is that
    ItemLedgEntry.SETRANGE("Item No.");
    
    in
    LOCAL PROCEDURE MakeSingleLevelAdjmt &#40;CU5895&#41; 
    ... 
          ItemLedgEntry.SETCURRENTKEY&#40;"Item No."&#41;; 
          ItemLedgEntry.FILTERGROUP&#40;9&#41;; 
          ItemLedgEntry.SETRANGE&#40;"Item No.",'70000’&#41;;  //add line, filter on the item no. 
          ItemLedgEntry.FILTERGROUP&#40;0&#41;; 
    
          IF NOT ItemLedgEntry.FIND&#40;'-'&#41; THEN  // that should be adjusted 
            EXIT&#40;FALSE&#41;; 
    ... 
            ItemLedgEntry.FIND&#40;'+'&#41;; 
           ItemLedgEntry.SETRANGE("Item No.");         // DO NOT DISABLE THIS LINE 
          UNTIL &#40;ItemLedgEntry.NEXT = 0&#41; OR LevelExceeded
    
    there for and why is "MakeSingleLevelAdjmt" defined as
    MakeSingleLevelAdjmt() : Boolean
    
    when that return value is never checked (or I'm I wrong?)?

    I'm quite new to Navision and especially to Adjust Cost - Item Entries but there seems to be a lot of problems with that batch job!
    Better to be critical then self-critical :)
  • kinekine Member Posts: 12,562
    Maybe stupid question but why is that
    Code:
    ItemLedgEntry.SETRANGE("Item No.");
    This loop is started on set of entries for many items. This takes the actual entry and it works on this entry. After the loop, it jumps on last entry of the same item and through .NEXT it step to next entry for another item... it means, each item is processed only once but this loop is not based on Item table but on Item Ledger Entry... :-)
    (it is a small trick)

    I hope that it'll help you... 8)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.