A couple of questions:
Is the PUMP OUTPUT used in any of your ladder logic?
How is your custom function, that contains the code that is supposed to control PUMP, invoked from the ladder logic? What ladder logic code triggers the custom function? Is the custom function run periodically, say every second?
Gary d