Aaargh! Where is that COMMIT?
This trick has nothing to do with the OMA but I really want to share it. Did you ever had to search for a COMMIT? The command CONSISTENT can help you with that.
This command is specially build to make sure that at the end of a transaction the G/L Accounts are in balance. In codeunit “Gen. Jnl.-Post Line” you will see the following C/AL statement:
GLEntry.CONSISTENT(
(BalanceCheckAmount = 0) AND
(BalanceCheckAmount2 = 0) AND
(BalanceCheckAddCurrAmount = 0) AND
(BalanceCheckAddCurrAmount2 = 0));
If you put a COMMIT somewhere is the posting routine after the consistency of the “General Ledger Entry” was set to false you will get the following beautiful error:
So if you have to find a COMMIT someday the only thing you have to do is first set a random table to CONSISTENT(FALSE) and the debugger will bring you to the first COMMIT.
PS: Kudos goes to rmv_RU. This topic was the first time I read about this.
Explore posts in the same categories: Object Manager


July 21st, 2012 at 2:48 pm
You can also use code coverage and then filter on commit and see where the commit is.
July 21st, 2012 at 3:03 pm
Yes you’re right! That’s sometimes an easier way to do it. Then you don’t have to modify any object.
But there are COMMIT’s in disguise that are harder to find. After an “IF CODEUNIT.RUN” there is also a commit that you cannot find with the code coverage. The CONSISTENT(FALSE) command is bullet proof.
You can also use it when you are debugging and you want to rollback your transaction at the end.