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

Smartforms to PDF

Former Member
0 Likes
633

hi all,

I tried to convert a smartform to a pdf, how can i do it? if you have an example will be useful.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
595

Please go through this link , hope you will get some useful stuff from this.

http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/62ae7fcd-0b01-0010-3e9d-a54f...

&----


*& Form f9100_save_to_pdf

&----


  • text

----


  • -->P_WS_FORMNAME text

----


FORM f9100_save_to_pdf using value(ws_formname).

data: i_lines TYPE tline OCCURS 0 WITH HEADER LINE.

data: ws_bin_size type i,

ws_filename type string.

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

format = 'PDF'

max_linewidth = 132

IMPORTING

bin_filesize = ws_bin_size

TABLES

otf = i_otf

lines = i_lines

EXCEPTIONS

err_max_linewidth = 1

err_format = 2

err_conv_not_possible = 3

err_bad_otf = 4

OTHERS = 5.

IF sy-subrc <> 0.

flg_exit = 'X'.

MESSAGE i050 WITH 'Error converting to PDF format'.

EXIT.

ENDIF.

  • Get the download path

PERFORM get_download_path CHANGING ws_filename.

if flg_exit = 'X'.

EXIT.

endif.

  • Download

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

bin_filesize = ws_bin_size

filename = ws_filename

filetype = 'BIN'

TABLES

data_tab = i_lines

EXCEPTIONS

file_write_error = 1

no_batch = 2

gui_refuse_filetransfer = 3

invalid_type = 4

no_authority = 5

unknown_error = 6

header_not_allowed = 7

separator_not_allowed = 8

filesize_not_allowed = 9

header_too_long = 10

dp_error_create = 11

dp_error_send = 12

dp_error_write = 13

unknown_dp_error = 14

access_denied = 15

dp_out_of_memory = 16

disk_full = 17

dp_timeout = 18

file_not_found = 19

dataprovider_exception = 20

control_flush_error = 21

OTHERS = 22.

IF sy-subrc <> 0.

MESSAGE i050 WITH 'Error while File download'.

flg_exit = 'X'.

EXIT.

ELSE.

MESSAGE i050 WITH 'File downloaded successfully '.

flg_exit = 'X'.

EXIT.

ENDIF.

Regards,

Prakash.

3 REPLIES 3
Read only

Former Member
0 Likes
596

Please go through this link , hope you will get some useful stuff from this.

http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/62ae7fcd-0b01-0010-3e9d-a54f...

&----


*& Form f9100_save_to_pdf

&----


  • text

----


  • -->P_WS_FORMNAME text

----


FORM f9100_save_to_pdf using value(ws_formname).

data: i_lines TYPE tline OCCURS 0 WITH HEADER LINE.

data: ws_bin_size type i,

ws_filename type string.

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

format = 'PDF'

max_linewidth = 132

IMPORTING

bin_filesize = ws_bin_size

TABLES

otf = i_otf

lines = i_lines

EXCEPTIONS

err_max_linewidth = 1

err_format = 2

err_conv_not_possible = 3

err_bad_otf = 4

OTHERS = 5.

IF sy-subrc <> 0.

flg_exit = 'X'.

MESSAGE i050 WITH 'Error converting to PDF format'.

EXIT.

ENDIF.

  • Get the download path

PERFORM get_download_path CHANGING ws_filename.

if flg_exit = 'X'.

EXIT.

endif.

  • Download

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

bin_filesize = ws_bin_size

filename = ws_filename

filetype = 'BIN'

TABLES

data_tab = i_lines

EXCEPTIONS

file_write_error = 1

no_batch = 2

gui_refuse_filetransfer = 3

invalid_type = 4

no_authority = 5

unknown_error = 6

header_not_allowed = 7

separator_not_allowed = 8

filesize_not_allowed = 9

header_too_long = 10

dp_error_create = 11

dp_error_send = 12

dp_error_write = 13

unknown_dp_error = 14

access_denied = 15

dp_out_of_memory = 16

disk_full = 17

dp_timeout = 18

file_not_found = 19

dataprovider_exception = 20

control_flush_error = 21

OTHERS = 22.

IF sy-subrc <> 0.

MESSAGE i050 WITH 'Error while File download'.

flg_exit = 'X'.

EXIT.

ELSE.

MESSAGE i050 WITH 'File downloaded successfully '.

flg_exit = 'X'.

EXIT.

ENDIF.

Regards,

Prakash.

Read only

Former Member
0 Likes
593

check this post,its having script to PDF conversion.you can use the same logic in your case also.

Regards

srikanth

Read only

ferry_lianto
Active Contributor
0 Likes
593

Hi Jose,

Here is a sample code for converting smartforms to pdf.

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/uuid/8fd773b3-0301...

Regards,

Ferry Lianto