It seems to me that this is being approached synchronously where perhaps it should be async:
1) User generates report
2a) Report gets printed
2b) Report gets emailed
2c) anything else gets done with the report...
OK, the process of generating a report is called Spooling.
The process of doing soething with that report is called De-Spooling.
Or call it EnQueuing and DeQueueing, whatever...
So a user does an SP-ASSIGN and sends spools one or more jobs.
Use SP-ASSIGN HSF20, to Spool the job into a hold file on formqueue 20, and leave it there.
Every print job has the User ID associated, and User email and other info can be put in the Users file or somewhere else application-specific.
That is your link between the job and the person who created it.
Now to De-Spool...
Use a phantom runner to periodically loop through jobs on F20.
SP-ASSIGN F21 or some other queue dedicated to generating a PDF
SP-EDIT #UMS
- # is the job#
- M suppresses further prompts
- S means Spool .. really DeSpool, but D already means Delete...
(Note, I can't take the time right now to set this up to QA, and that may not be the exact/correct sequence.)
So you've now De-Spooled that job to PDF and I believe the formqueue of the job has been reassigned to F21, so it won't get selected again.
You now have a PDF and a User ID, get the email address via lookup, and use whatever tool that you prefer to do the email with the PDF as an attachment.
On completion, DELETE PEQS # to remove the job.
Or SP-EDIT #MD
Or SP-EDIT #MSZ on the initial de-spool and the job will be deleted immediately on completion of the PDF generation
Is that a solution to this challenge?
HTH
T