I think members are not sure how to test it. Let me explain it.
Suppose if the Next Available Reference for Journal Entry is JE222 in Transaction References. Change it to JE220. Now if you will make the Journal Entry you will get the message "Reference already in use".
Now place the above code in core and test now. You will see that the message will not appear and the system will itself increment the values and record the transaction with Reference JE222.
I hope now someone can test it and give feedback to @joe.