Application Development 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: 

CONVERT_OTF_2_PDF problem

Former Member
0 Kudos

Hi all

I'm trying to send a sapscript via email.

The scenario is the sequent.

The mail is send correctly but I am not able to open the pdf file with acrobat reader.

I try to open the pdf file with notepad and it looks like other pdf file.

It's possible that something doesn't work correctly in the FM CONVERT_OTF_2_PDF?

bye

enzo

6 REPLIES 6

Former Member
0 Kudos

Hi,

I too had the same requirement here is the sample code. Please check it, it may helpful if yes try to assign some app. points.

sample code:

-


REPORT YFINAL.

  • Data declarations

TYPES: pdf_nuc_line_t TYPE SOLI.

DATA: lt_pdf_nuc_data TYPE STANDARD TABLE OF SOLI.

data : output_options type ssfcompop, " To hold output options

control_parameters type ssfctrlop, " To hold control parameters

output_data type ssfcrescl, " To hold Output information

v_pdf_len type i,

pdf_table type rcl_bag_tline,

l_cline TYPE SOLISTI1.

DATA: FM_NAME TYPE RS38L_FNAM.

----


  • SELETION SCREEN

----


SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

data : p_FNAME TYPE RS38L_FNAM. "Smartform name

p_fname = 'YMSGTEST'.

SELECTION-SCREEN END OF BLOCK B1.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING FORMNAME = p_fname

  • variant = ' '

  • direct_call = ' '

IMPORTING FM_NAME = FM_NAME

EXCEPTIONS NO_FORM = 1

NO_FUNCTION_MODULE = 2

OTHERS = 3.

if sy-subrc = 0.

write FM_NAME.

endif.

  • Set the output options and control parameters

  • Set control parameters to get the output format (OTF) from Smart Forms

control_parameters-no_dialog = 'X'.

control_parameters-getotf = 'X'.

control_parameters-langu = sy-langu.

  • Get device type

call function 'SSF_GET_DEVICE_TYPE'

EXPORTING

i_language = control_parameters-langu

IMPORTING

e_devtype = output_options-tdprinter

EXCEPTIONS

no_language = 1

language_not_installed = 2

no_devtype_found = 3

system_error = 4

others = 5.

if sy-subrc <> 0.

endif.

call function FM_NAME

EXPORTING

  • ARCHIVE_INDEX =

  • ARCHIVE_INDEX_TAB =

  • ARCHIVE_PARAMETERS =

CONTROL_PARAMETERS = control_parameters

  • MAIL_APPL_OBJ =

  • MAIL_RECIPIENT =

  • MAIL_SENDER =

OUTPUT_OPTIONS = output_options

  • USER_SETTINGS = 'X'

IMPORTING

  • DOCUMENT_OUTPUT_INFO =

JOB_OUTPUT_INFO = output_data

  • JOB_OUTPUT_OPTIONS =

exceptions

formatting_error = 1

internal_error = 2

send_error = 3

user_canceled = 4

others = 5

.

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

  • now convert the final document (OTF format) into PDF format

call function 'CONVERT_OTF'

exporting

format = 'PDF'

  • MAX_LINEWIDTH = 132

  • ARCHIVE_INDEX = ' '

  • COPYNUMBER = 0

importing

bin_filesize = v_pdf_len

tables

otf = output_data-otfdata

lines = PDF_TABLE

exceptions

err_max_linewidth = 1

err_format = 2

err_conv_not_possible = 3

err_bad_otf = 4

others = 5

.

  • To convert PDF file to Binary

call function 'QCE1_CONVERT'

tables

t_source_tab = PDF_TABLE

t_target_tab = lt_pdf_nuc_data

EXCEPTIONS

CONVERT_NOT_POSSIBLE = 1

OTHERS = 2

.

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE =

FILENAME = 'c:/testhem/myfile.pdf'

FILETYPE = 'BIN'

TABLES

DATA_TAB = lt_pdf_nuc_data.

Regards,

Suman

former_member188685
Active Contributor
0 Kudos

I feel there is some problem in sending the mail, to confirm that just download that to your PC and check

that you can open it or not .

this you can cross check whether you are sending correctly or not..,.

regards

vijay

0 Kudos

The problem is the same if I download the internal table with pdf file with gui_download FM.

So I don't think it's a email problem, isn't it?

Bye

enzo

0 Kudos

yeah it is not related to E-mail,

when you tried opening it then how the data displayed

is it readable or something else...

regards

vijay

Former Member
0 Kudos

Hi,

Is the file type you are using is "BIN" like in the following code:

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE =

FILENAME = 'c:/testhem/myfile.pdf'

FILETYPE = 'BIN'

TABLES

DATA_TAB = lt_pdf_table.

and use lt_pdf_table in the "objbin" of the mail sending FM.

Regards,

Suman

0 Kudos

Hi all,

now I'm able to download the file and see it correctly.

Now the problem is the email.

It's no possile opening the file attached to the email .

Any suggestions?

thank enzo