Hi Sam ,
The problem is that program is taking a lot time to generate the output. So do some modifications to it.You can check which statement is checking more time using the SAT transaction code and try to use primary keys in the selection query this will improve your performance.To know more do paste your code for us to help you in a better way.
Regards
Nav