Convert Spool Request(Generated Background Job ) Into PDF

Standard FM-‘CONVERT_OTFSPOOLJOB_2_PDF’ is used to convert script otx spool to PDF.

Standard FM-‘CONVERT_ABAPSPOOLJOB_2_PDF’ is used to convert background job spool to PDF.

Step1. Here we have a simple program. Execute it.


Step2. We have the below output.


Step3. Go to Tx- SM36 and create and schedule a background job for the above report.


Step4. Background Job program name.


Step5. In Tx- SM37 run the job.The spool is generated. Select the spool.


Step6. Spool number is 3173 and click on the icon under type.


Step7. So here is the spool output as a result of background job.


Step8. The spool entry in the data base table.


Step9. Here is the program that reads the spool and converts it into PDF and saves it in a destination folder.



PARAMETERS spool_no TYPE tsp01rqident DEFAULT ‘3173’,
path TYPE string DEFAULT ‘C:\Users\Documents\DOWNLOAD\BGSPOOL.PDF’.

DATA ls_spool TYPE tsp01,
lt_pdf TYPE TABLE OF tline,
objtype LIKE rststypetype,
file_size TYPE i.

START-OF-SELECTION.

SELECT SINGLE FROM tsp01 INTO ls_spool WHERE rqident spool_no.
IF sysubrc IS INITIAL .
CALL FUNCTION ‘RSTS_GET_ATTRIBUTES’
EXPORTING
client          ls_spoolrqclient
name          ls_spoolrqo1name
part          1
IMPORTING
objtype       objtype.

IF objtype(3‘OTF’” OTF TEXT- SAP SCRIPT OUTPUT


CALL FUNCTION ‘CONVERT_OTFSPOOLJOB_2_PDF’
EXPORTING
src_spoolid     ls_spoolrqident
no_dialog       ‘ ‘
IMPORTING
pdf_bytecount   file_size
TABLES
pdf             lt_pdf.

ELSEIF objtype ‘TEXT’“Job spool output of background report job


CALL FUNCTION ‘CONVERT_ABAPSPOOLJOB_2_PDF’
EXPORTING
src_spoolid          ls_spoolrqident
no_dialog            ‘ ‘
IMPORTING
pdf_bytecount        file_size
TABLES
pdf                  lt_pdf.


ENDIF.

CALL FUNCTION ‘GUI_DOWNLOAD’
EXPORTING
bin_filesize file_size
filename     path
filetype     ‘BIN’
TABLES
data_tab     lt_pdf.


ENDIF.


 

Step10. Execute the report and provide the spool number and a destination path to download the PDF.


Step11. Destination folder.


Step12. Execute it.


Step13. Destination folder. open the file.


Step14. So here we have the PDF.


 

 

One comment

  1. ON USING CONVERT_OTFSPOOLJOB_2_PDF The script form is getting printed multiple times
    1st time if i will proccess it is prints one form if 2 nd time I will process it will print same form of one page 2 forms and so on..

    Like

Leave a Reply