what is the "check engine" code thrown off after the car goes into trans program. have you attempted to retrieve the engine code after the car does this? if not, you may gain some insight as to any external factors (such as throttle position sensors, et cetera--i know you ruled the tps out by replacing it)
next time, after it goes "limp",check the engine codes by following the procedure here:
http://www.bmwe34.net/e34main/trouble/engine_codes.htm