Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Not able to convert spool output to PDF file properly

Hi guys,

i have got spool which contains russian characters which needs to be converted to PDF file.

Note: ******Assuming user enters only one spool in S_Spool*******

I am using following code to do this:

**---- Get Spool ID Details from TSP01

select * from tsp01 into table i_tsp01 where rqident eq s_spool.

**---- Sort Table in Ascending order based on Spool Id

sort i_tsp01 by rqident.

**---- Get information about Multiple spools

loop at i_tsp01.

**---- Get Multiple Spool information

call function 'RSPO_RETURN_SPOOLJOB'

exporting

rqident = i_tsp01-rqident

tables

buffer = i_spool_table

exceptions

no_such_job = 1

job_contains_no_data = 2

selection_empty = 3

no_permission = 4

can_not_access = 5

read_error = 6

type_no_match = 7

others = 8.

if sy-subrc = 0.

endif.

**---- Get the Last line index (Number of Lines)

describe table i_spool_table lines v_lines.

i_otf[] = i_spool_table[].

endloop.

**---- Convert the OTF information to PDF.

call function 'CONVERT_OTF_2_PDF'

importing

bin_filesize = v_size

tables

otf = i_otf

doctab_archive = i_doc

lines = i_pdf

exceptions

err_conv_not_possible = 1

err_otf_mc_noendmarker = 2

others = 3.

if sy-subrc <> 0.

message i002(sy) with 'Cannot convert to PDF, exiting....'.

leave program.

endif.

DATA: v_numbytes TYPE i.

DATA : v_return1(128).

CONCATENATE 'C:\' 'F_spool' '.pdf' INTO v_return1.

CONDENSE v_return1.

CALL FUNCTION 'WS_DOWNLOAD'

EXPORTING

bin_filesize = v_size

filename = v_return1

filetype = 'BIN'

IMPORTING

filelength = v_numbytes

TABLES

data_tab = i_pdf

EXCEPTIONS

file_open_error = 1

file_write_error = 2

invalid_filesize = 3

invalid_type = 4

no_batch = 5

unknown_error = 6

invalid_table_width = 7

gui_refuse_filetransfer = 8

customer_error = 9

OTHERS = 10 .

IF sy-subrc NE 0.

EXIT.

ENDIF.

i have already tried standard pgm : RSTXPDFT4. But it does not work.

Suitable answers will be rewarded.

Thanks,

GURU

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question