Posting a Journal Starts on Active Line

Ever had to post a large journal batch and an error was thrown just before all lines were checked? So you manage to identify the right journal line somewhere at the bottom of your batch. You fix the issue and post again. But now immediately the systems errs on the same line because of another issue.

Ever wondered why it didn’t err instantly the first time? Reread the title of this blog post.

Code Behind

Let’s have a look at the code behind. Did you ever wonder about this piece of code in the Code function-trigger in Post Batch codeunits, like codeunit 13 (Gen. Jnl.-Post Batch)?

  // Check lines
  LineCount := 0;
  StartLineNo := “Line No.”;

  REPEAT
    LineCount := LineCount + 1;
    Window.UPDATE(2,LineCount);
    …
    GenJnlCheckLine.RunCheck(GenJnlLine5,TempJnlLineDim);
    …
    IF NEXT = 0 THEN
      FINDFIRST;
  UNTIL “Line No.” = StartLineNo;

As you probably know: before even trying to post the journal lines NAV is first checking all the journal lines – see the progress dialog!

It loops through the lines and calls for each line the RunCheck routine. What you might never have realized is that this loop does not start a the top of the lines. No, it starts with the active line (StartLine).

From that line on it:

  • runs to the last line (NEXT = 0)
  • jumps to the top (FINDFIRST) 
  • runs down again until it hits the StartLine again (“Line No.” = StartLineNo)

And after tis checking are the lines posted in the same order? No, don’t worry, after this all lines are posted from top to bottom.

Leave a Reply

Your email address will not be published. Required fields are marked *