In the Dodge's, the PCM programming was different between between the two different styles, the values the sensor picked up are different and would also use the solenoids to control the pressures different. You could connect the plug on the transmission on an older truck, but would cause it to go into limp mode if it had the newer sensor/solenoid in it.
Searching for the 42re valve body, it comes up with only two different versions. One with the old style electronics and one with the new style, all internal parts are the same.
they have different springs, separator plates, and switch valves. any good shift kit for "all years" includes parts specifically for the different valve bodies. there were at least 3 revisions during the zj years.
'97 zj 5.2, some stuff, some other suff, and some things that even work sometimes.
So would a new trans case with the old valve body/sensor work? I haven't seen the inside of an electronic trans so I don't know if it's possible... last auto trans I rebuilt was a 727 in the early 80s.
unfortunately the 97 does not have a flashable ECM so it sounds like the other option would be some sort of aftermarket TCM (ie megashift. see http://www.msgpio.com/manuals/mshift/index.html for those that don't know what I'm talking about).
There is truth to a few comments in this thread. I have a 97 ZJ and the transmission was cracked. I picked up a 94 42RE and even then there were a few tweaks. The dipstick is on the opposite side, so had to come up with a makeshift bracket to bolt it to the block/housing. My only other concern would be how it bolts to the tcase, if its the same and the input shaft sizing.
Check Craigslist and local junkyards. A few near me have sales every now and again where you could pick up a trans for $100-200 and it comes with a 1-year warranty. I found my trans and NP231 tcase together for $200!