FINDFIRST used with REPEAT in posting routines in NAV 2017

piktazpiktaz Member Posts: 9

I came across this code in the Sales-Post codeunit in NAV 2017


Couldn't believe what I see so checked the Purch.-Post codeunit and it was exactly the same, FINDFIRST accompanied by REPEAT loop.

I checked the documentation (NAV 2016) and it still explicitly says FINDFIRST should never be used in combination with REPEAT UNTIL.

Has something changed in NAV 2017 regarding this?



  • Options
    KishormKishorm Member Posts: 921
    At first I thought it was because the GetNextSalesLine() function was doing something funky but it's not really - it goes through all the sales lines until NEXT returns 0 and then does and extra loop for posting a prepayment line.

    In my mind there's no valid reason that this shouldn't be a FINDSET.
  • Options
    piktazpiktaz Member Posts: 9
    Yep, my initial thoughts were GetNextSalesLine() was doing something sophisticated. But reality is it just a glorified Record.NEXT fetch function.
Sign In or Register to comment.