cancel
Showing results for 
Search instead for 
Did you mean: 

Error in PDF Conversion

Former Member
0 Kudos

Hi..am converting spool output to pdf using the FM 'CONVERT_ABAPSPOOLJOB_2_PDF'. But the resultant output table contains just scrap.

My internal output table contains 10 columns and 7 rows.

Kindly let me know a solution for this.

CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'

EXPORTING

src_spoolid = i_tsp01-rqident

no_dialog = ' '

dst_device = c_device

pdf_destination = ' '

IMPORTING

pdf_bytecount = v_size

TABLES

pdf = it_pdf_output

EXCEPTIONS

err_no_abap_spooljob = 1

err_no_spooljob = 2

err_no_permission = 3

err_conv_not_possible = 4

err_bad_destdevice = 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

OTHERS = 12.

Useful answers will be rewarded.

Regards

Accepted Solutions (1)

Accepted Solutions (1)

former_member188685
Active Contributor
0 Kudos

>But the resultant output table contains just scrap.

That data will be in binary format, you can't understand that. PDF reader can read/understand those instructions. what ever you are doing is correct. the part which you showed.

Former Member
0 Kudos

Hi...thanks for your reply. when i try to open the PDF..it says 'There was an error opening this document. The file is damaged and could not be repaired'.

Is there any FM to be used to further convert the document.

Thanks

former_member188685
Active Contributor
0 Kudos

Try to imitate the programs

RSTXPDF4
RSTXPDFT4

just check how it is performed in the above programs.

Former Member
0 Kudos

it is solved....thanks a lot

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Following code works for me. try to compare this with your code.

IF sy-subrc EQ 0.

NEW-LINE.

WRITE: sy-uline NO-GAP.

NEW-PAGE PRINT OFF.

l_spool = sy-spono.

*--- create unique filename

WRITE: sy-uzeit TO l_time USING NO EDIT MASK.

CONCATENATE sy-uname l_time 'cckps.pdf' INTO x_filename.

PERFORM convert_spool_to_pdf USING sy-spono

x_filename.

ENDIF.

&----


*& Form CONVERT_SPOOL_TO_PDF

&----


FORM convert_spool_to_pdf USING p_spool LIKE sy-spono

p_x_filename.

DATA: l_spool LIKE tsp01-rqident,

l_pdf_bytecount TYPE i,

l_pdf_spoolid LIKE tsp01-rqident,

l_list_pagecount TYPE i,

l_btc_jobname TYPE tbtcjob-jobname,

l_btc_jobcount TYPE tbtcjob-jobcount,

lt_pdf LIKE STANDARD TABLE OF tline WITH HEADER LINE,

l_file TYPE string

VALUE '/usr/sap/&/EHS_DOC/'.

REPLACE '&' WITH sy-sysid INTO l_file.

CONDENSE l_file NO-GAPS.

CONCATENATE l_file p_x_filename INTO l_file.

l_spool = p_spool.

CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'

EXPORTING

src_spoolid = l_spool

IMPORTING

pdf_bytecount = l_pdf_bytecount

pdf_spoolid = l_pdf_spoolid

list_pagecount = l_list_pagecount

btc_jobname = l_btc_jobname

btc_jobcount = l_btc_jobcount

TABLES

pdf = lt_pdf

EXCEPTIONS

err_no_abap_spooljob = 1

err_no_spooljob = 2

err_no_permission = 3

err_conv_not_possible = 4

err_bad_destdevice = 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

OTHERS = 12.

OPEN DATASET l_file FOR OUTPUT IN BINARY MODE.

LOOP AT lt_pdf.

TRANSFER lt_pdf TO l_file.

ENDLOOP.

CLOSE DATASET l_file.

ENDFORM. " CONVERT_SPOOL_TO_PDF

Thanks,

Sree.