Connecting more than one serial device to PIC16f877a
You're approaching the problem in the wrong way. You have two devices that put out serial data, so you need a microcontroller with two UARTS. Luckily, such things are available, for example among the PIC24's there are chips that have two UART ports and two I2C ports. These are still PIC, so you can apply your PIC16 skills.

Match the microcontroller to the application! Do not have a "pet" microcontroller that you use for everything, no matter what.

There isn't much reason to use a PIC16 today in a new design. It's great that Microchip stands behind them and still makes them. But the primary value of this is that you can replace a nonworking one in an old device.