Which version and support pack you are in?
I am on bpc 10.1 sp 8. and I do see a text box which specifies "Raise message when package link failed or canceled" in UJD_TEST_PACKAGE_LINK.
So you do not have to code anything, just put "Y"
If you are in a lower support pack you need to code it out, I do not have it handy