Let me see if I've understood exactly your problem.
There's a piping at your plant for caustic service. In chemistry, by caustic service it's meant caustic soda (sodium hydroxide) at a minimum concentration of 5%. Other strong alkalyne substances also fall into this classification, such as caustic potash, concentrated sodium carbonate etc.
Concentrated ammonia, on the other hand, is not considered a caustic substance because ammonia is a weak alkaly.
The piping has been put out of service to weld a new flange on it, and you're worried as to whether it can be welded because there is a chance of cracking due to the caustic service the piping has been subjected to.
Am I right up to this point?
If so, let's put our horse sense to work.
Why should cracking occur? Because it's still wet with the caustic substance, is the logical answer.
If we get rid of the caustic substance could we be able to make the weld? I would say so.
How can we get rid of the caustic substance? By washing the piping inside surface with plenty of water. The more water, the better.
How will we know that the caustic substance has been washed away? By testing the outflowing water with phenolphtaleine. Take a sample of water from time to time and test it with a few drops of phenolphtaleine. If it gets red, the washing is not complete. When it doesn't get red any more, the washing is complete and there's no caustic in contact with the pipe material.
At this point, in my opinion, the welding may be carried out.
Of course, you'll run into another problem: how to dispose the washing water containing caustic substance in an "environment friendly" manner. You should make some further research (this is the site of the AWS, not the EPA's).
Giovanni S. Crisi
Sao Paulo - Brazil