Warning - this is a very powerful and dangerous script
AND IT IS UNTESTED IN A LIVE ENVIRONMENT
I'm just posting it here as a shell for future use.
USE AT YOUR OWN RISK.
BACKUP YOUR DATA.
That being said, this script is designed to look at all the unapplied payments in your environment and insert apply records.
There are three scripts. The first backs up RM20101. The second restores it. The third is the script that does the work.