One way of debuging programs which are already running in background is via transaction SM50. SM50 displays a
list of process running in the SAP server. In order to debug the program select it from the list and go to Menu option:
Administration->Program->Debugging (this may have been Program/Mode->Program->Debugging in older versions of SAP).