You will have to change some of the coding. but not all of them. You should use the registers in PIC16F877A for the modifications. And you will not need to cahnge any hardware. Just check the Datasheets and compare if you are not sure.
But the PIC18F452 is more powerful than tha PIC16F877A. So i suggest you to use PIC18F452, because you could use it for some other project aswell when you are finished with your current one(if it is not permanant)