I am using PIC 16F877A for a big project, I already used all available ports, but having some problems with PORTA.
I want to use PORTA as a digital I/O port. I just found in 16F877A datasheet how to configure pins 0,1,2,3 and 5 as digital I/O (ADCON1 = %00000111); but can't find how to configure pin 4.
RA4 should work fine as an open collector output with a pull-up resistor to +5v.
One thing that could cause you a problem is that RA4 is also used as an output for the comparator module.
The comparator module is turned off by default at power-on, so should not cause any problem unless you have enabled it.
See section 12 of the data sheet.