0% found this document useful (0 votes)
99 views3 pages

Convert - Copy OTF Spool To Create New PDF Spool

Uploaded by

heavy
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
99 views3 pages

Convert - Copy OTF Spool To Create New PDF Spool

Uploaded by

heavy
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 3

8/6/24, 12:28 SAP ABAP: Convert/Copy OTF spool to create new PDF spool.

Convert/Copy OTF spool to create new PDF spool.

Code:

REPORT zr_spool_pdf LINE-SIZE 80.


*
* Read spool job contents (OTF or ABAP list) and convert
* to PDF, download PDF
TABLES: tsp01.
PARAMETERS:
spoolno LIKE tsp01-rqident,
p_dele AS CHECKBOX.

DATA otf LIKE itcoo OCCURS 100 WITH HEADER LINE.


DATA cancel.
DATA pdf LIKE tline OCCURS 100 WITH HEADER LINE.
DATA: numbytes TYPE i,
arc_idx LIKE toa_dara,
pdfspoolid LIKE tsp01-rqident,
jobname LIKE tbtcjob-jobname,
jobcount LIKE tbtcjob-jobcount,
is_otf,
txt(80) TYPE c.
DATA: client LIKE tst01-dclient,
name LIKE tst01-dname,
objtype LIKE rststype-type,
type LIKE rststype-type,
spoolid TYPE rspoid,
pages TYPE i,
pdfstr TYPE string,
pdfxstr TYPE xstring.
START-OF-SELECTION.
SELECT SINGLE * FROM tsp01 WHERE rqident = spoolno.
IF sy-subrc <> 0.
MESSAGE 'Spool not available' TYPE 'E' .
EXIT.
ENDIF.

client = tsp01-rqclient.
name = tsp01-rqo1name.
CALL FUNCTION 'RSTS_GET_ATTRIBUTES'
EXPORTING
authority = 'SP01'
client = client
name = name
part =1
IMPORTING
type = type
objtype = objtype
EXCEPTIONS
fb_error =1
fb_rsts_other = 2
no_object =3
no_permission = 4.

https://vaigundaraja65.blogspot.com/2020/08/convertcopy-otf-spool-to-create-new-pdf.html 1/3
8/6/24, 12:28 SAP ABAP: Convert/Copy OTF spool to create new PDF spool.
IF objtype(3) = 'OTF' OR objtype+1(3) = 'OTF'. "Script OTF

CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'


EXPORTING
src_spoolid = spoolno
no_dialog =''
* DST_DEVICE =
* PDF_DESTINATION =
IMPORTING
pdf_bytecount = numbytes
pdf_spoolid = pdfspoolid
* OTF_PAGECOUNT =
btc_jobname = jobname
btc_jobcount = jobcount
TABLES
pdf = pdf
EXCEPTIONS
err_no_otf_spooljob =1
err_no_spooljob =2
err_no_permission =3
err_conv_not_possible =4
err_bad_dstdevice =5
user_cancelled =6
err_spoolerror =7
err_temseerror =8
err_btcjob_open_failed =9
err_btcjob_submit_failed = 10
err_btcjob_close_failed = 11.
IF sy-subrc NE 0 .
MESSAGE 'Spool OTF to PDF Conversion errro' TYPE 'E' .
ENDIF.

ENDIF.

* ->Convert PDF output to XSTRING


FIELD-SYMBOLS:<p> TYPE x. " <p> type any.
LOOP AT pdf .

ASSIGN pdf TO <p> CASTING TYPE x.

CONCATENATE pdfxstr <p> INTO pdfxstr IN BYTE MODE.


ENDLOOP.

pages = tsp01-rqapprule .

CALL FUNCTION 'ADS_CREATE_PDF_SPOOLJOB'


EXPORTING
* printer = 'ZMAIL' "tsp03d-patype should be PDF use any one
dest = 'ZMAI' "tsp03d-patype should be PDF use any one
pages = pages
pdf_data = pdfxstr
IMPORTING
spoolid = spoolid
EXCEPTIONS
no_data =1
not_pdf =2
wrong_devtype =3
operation_failed = 4
cannot_write_file = 5
device_missing =6
no_such_device =7
OTHERS = 8.

WRITE: 'Old spool : ', spoolno .


WRITE: 'NEW spool : ', spoolid .

IF p_dele = 'X'.
CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
EXPORTING
https://vaigundaraja65.blogspot.com/2020/08/convertcopy-otf-spool-to-create-new-pdf.html 2/3
8/6/24, 12:28 SAP ABAP: Convert/Copy OTF spool to create new PDF spool.
spoolid = spoolno
allow_commit = 'X' .
ENDIF.

Posted by Vaigunda raja at 02:45


Labels: Convert/Copy OTF spool to create new PDF spool.

https://vaigundaraja65.blogspot.com/2020/08/convertcopy-otf-spool-to-create-new-pdf.html 3/3

You might also like