Is it possible you ever had to develop some kind of process to post general journal entries as long as it creates them? Possibly, you end up with the solution of sending all them into an empty batch section and them post it, but there are more professional ways to do this if you really stop and understand how the posting routines work.

If you look at how NAV posts entries you probably have noticed already that there are 3 basic codeunits to make this possible:

  • Codeunit 11 - Gen. Jnl.-Check Line: Used to check if the line is correct.
  • Codeunit 12 - Gen. Jnl. Post Line: Used to post a single line from journal.
  • Codeunit 13 - Gen. Jnl. Post Batch: Used to post an entire batch section.

The main important idea here is to understand how these objects are called when we post a batch section journal manually: When we press F9, codeunit 13 is called first, It acts as the orchestrator to post every single line and COMMIT the transaction when necessary. Each line is posted using codeunit 12 and, at the same time, codeunit 12 calls codeunit 11 to test the line before start processing it.

That means, that if you need to build a process that creates a transaction, this can use table 81 as a temporary table and call codeunit 12 to process it. You don't need to use template or batch name. At the end of each transaction, just call the COMMIT and the consistent function will be triggered to ensure the transaction is balanced. In the meantime, transactions won't be fully saved on the database so they can remain inconsistent until you decide to check programmatically or by ending the current process.