Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Convert to PDF

Former Member
0 Likes
877

Is it possible to download a SAP Script output to PDF. If yes how can I do it.

Please help.

Regards

Binoo

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
841

Hi!

Proceed as follows:

1. Get SAP Script output in OTF-format:

...

options-tdgetotf = 'X'.

CALL FUNCTION 'OPEN_FORM'

EXPORTING

options = options

...

CALL FUNCTION 'CLOSE_FORM'

  • IMPORTING

  • RESULT =

  • RDI_RESULT =

TABLES

otfdata = it_otf

EXCEPTIONS

unopened = 1

bad_pageformat_for_print = 2

send_error = 3

spool_error = 4

OTHERS = 5.

2. Then convert it to PDF:

DATA:

it_pdf LIKE tline OCCURS 100 WITH HEADER LINE,

v_len_in LIKE sood-objlen.

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

format = 'PDF'

max_linewidth = 132

  • ARCHIVE_INDEX = ' '

IMPORTING

bin_filesize = v_len_in

TABLES

otf = it_otf

lines = it_pdf

EXCEPTIONS

err_max_linewidth = 1

err_format = 2

err_conv_not_possible = 3

OTHERS = 4

.

Now it_pdf contains binary data for PDF-document of SAP Script. You can download it to frontend (application server) or send as mail attachment accordingly.

Regards,

Maxim.

Is it possible to download a SAP Script output to PDF. If yes how can I do it.

Please help.

Regards

Binoo

6 REPLIES 6
Read only

Former Member
0 Likes
841

Hi,

Look at the code....

  • Converting OTF data to single line

LOOP AT i_otf INTO w_otf.

CONCATENATE w_otf-tdprintcom w_otf-tdprintpar

INTO w_pdf.

APPEND w_pdf TO i_content_txt.

ENDLOOP.

  • Converting to PDF Format

CALL FUNCTION 'SX_OBJECT_CONVERT_OTF_PDF'

EXPORTING

format_src = c_otf

format_dst = c_pdf

devtype = c_printer

CHANGING

transfer_bin = w_transfer_bin

content_txt = i_content_txt

content_bin = i_content_bin

objhead = i_objhead

len = v_len_in

EXCEPTIONS

err_conv_failed = 1

OTHERS = 2.

v_size = v_len_in.

  • Downloading the PDF File

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

bin_filesize = v_size

filename = c_name

filetype = c_bin

TABLES

data_tab = i_content_bin.

************

Have a look at these FM also

CONVERT_OTFSPOOLJOB_2_PDF ==== converts a OTF spool to PDF (i.e. Sapscript document)

SX_OBJECT_CONVERT_OTF_PDF ==== Conversion From OTF to PDF (SAPScript conversion)

Thanks.

If this helps you reward with points.

Read only

0 Likes
841

Hai Deepak,

Can you please exlain a little more.

LOOP AT i_otf INTO w_otf.

CONCATENATE w_otf-tdprintcom w_otf-tdprintpar

INTO w_pdf.

APPEND w_pdf TO i_content_txt.

ENDLOOP.

what is the type of i_otf,i_content_txt.

what is the data inside it and how is it populated.

what is c_otf ,c_pdf ,w_transfer_bin,i_content_bin used in the FM

Please reply.I will surely reward points

Binoo

Read only

Former Member
0 Likes
841

RSTXPDFT4 will help u in this

Read only

0 Likes
841

RSTXPDFT4 program will help u in this

Read only

andreas_mann3
Active Contributor
0 Likes
841

Hi Binoo,

or use report RSTXPDFT4

regards

Andreas

Read only

Former Member
0 Likes
842

Hi!

Proceed as follows:

1. Get SAP Script output in OTF-format:

...

options-tdgetotf = 'X'.

CALL FUNCTION 'OPEN_FORM'

EXPORTING

options = options

...

CALL FUNCTION 'CLOSE_FORM'

  • IMPORTING

  • RESULT =

  • RDI_RESULT =

TABLES

otfdata = it_otf

EXCEPTIONS

unopened = 1

bad_pageformat_for_print = 2

send_error = 3

spool_error = 4

OTHERS = 5.

2. Then convert it to PDF:

DATA:

it_pdf LIKE tline OCCURS 100 WITH HEADER LINE,

v_len_in LIKE sood-objlen.

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

format = 'PDF'

max_linewidth = 132

  • ARCHIVE_INDEX = ' '

IMPORTING

bin_filesize = v_len_in

TABLES

otf = it_otf

lines = it_pdf

EXCEPTIONS

err_max_linewidth = 1

err_format = 2

err_conv_not_possible = 3

OTHERS = 4

.

Now it_pdf contains binary data for PDF-document of SAP Script. You can download it to frontend (application server) or send as mail attachment accordingly.

Regards,

Maxim.