Reputation: 4378
I have a program that outputs some logs to the spool log via WRITE
statements. When I run the program in foreground those WRITEs are plainly visible on the screen but if I run the program with the same parameters in background (via F9 from the selection screen) or plan it in a background job, SM37 indicates that no output list is available for the job in the spool.
If I check table TBTCP ("Background Job Step Overview") I find that the LISTIDENT field is empty for my job. However, an output list was sent to the spool as I can find it in transaction SP01 (table TSP01).
Further investigation shows that this only occurs when I process a ROLLBACK WORK
statement in my program.
Upvotes: 3
Views: 7270
Reputation: 4378
This behaviour seems to occur because the output list in the spool is not linked to the job until the program finishes processing, which triggers an implicit COMMIT operation. If you run a ROLLBACK without first having done a COMMIT, the pending save of the relationship between job and spool is apparently lost.
To avoid this any program that has the potential to do a ROLLBACK should run a COMMIT WORK [AND WAIT]
before starting its main logic. However it's not enough to just do a commit: there also needs to be at least one line in the output list before the link will be saved.
So, first initialise the output list with a WRITE
statement, then run a COMMIT WORK
to link the output list spool to the job.
This can be done in the INITIALIZATION
step of the program or START-OF-SELECTION
as long as you commit prior to any code that might do a rollback.
Upvotes: 8