1999 chevy tahoe 5.7 engine

can i buy used engine control modular and change it myself

On a 99, I believe it is possible some of the newer cars are not quite as simple. I would just check the engine code letter in your VIN and match that to the one on a possible donor vehicle. This would remove differences like particular year engine calibrations and possibly differences in sensors used between different applications. The only other variable, and I am not sure if these trucks have a separate body control module, would be the rear axle ratio could throw off some programming for things like the speedometer. You could be even more picky and check for things like the axle code. GM places a big label with a bunch of 3 letter/number codes on it. You would be looking for the GUx code to be the same.
As a last resort, I believe a dealer can reprogram a module for you but I have never done that. I would still look for the same engine code letter before getting started down that path.