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.
ENDIF.
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?