We have made an enhancement to the FM FPCOMP_JOB_CLOSE, where we replace the PDF stream in the job with a PDF stream retrieved earlier for printing delivery notes.
The delivery note is printed using VL02N->Outbound Delivery->Issue Deilvery Output. The output is then selected and either Print Preview or Print are selected.
READ TABLE job-documents INDEX 1 ASSIGNING FIELD-SYMBOL(<fs_doc>).
IF sy-subrc = 0.
<fs_doc>-pdf = lv_pdf_stream.
When the print preview is shown all is good, and the correct print is previewed. However when an actual printout is requested, then it is the original layout that is printed regardless of whether the preview have been shown or not.
Is it not possible to replace the content of a print job?
I'd say that you don't give enough information because if you replace the PDF, then it's impossible that something else is printed. So, you should elaborate.
My 2 cents: as you're talking about FPCOMP, I guess it's an Adobe form generated through Adobe Document Services, and so maybe the issue is about the cache in the ADS, which still points to the "original layout". This was already discussed in the forum how to clear the cache. That doesn't explain why it's different between preview and actual printing, maybe it's a matter of different application server, or whatever. Anyway, clearing the cache should solve the issue.