2006 Oct 06 3:29 PM
Hi,
My requirement is to send a SAP Script as a PDF attachment to an external mail id.
Problem:
Currently we are able to send an email along with the attachment to Organization's E-Mail IDs. The attachment goes with an ".pdf" extension and is opening as required.
Now while sending mail to an external id, the extension of file is changed internally to ".ps". Here sending mail is perfectly fine even with attachments.
But the requirement is a file with .PDF extension directly (not .PS).
Please let me know how can I achieve this.
Regards,
Pritam
2006 Oct 06 3:40 PM
I don't understand very well as this is up to you to decide of the file extension.
Do you use FM 'SX_OBJECT_CONVERT_OTF_PDF' ?
The extension is put the it_mailpack-obj_name parameter of 'SO_NEW_DOCUMENT_ATT_SEND_API1'.
Best regards,
Erwan
2006 Oct 06 3:40 PM
I don't understand very well as this is up to you to decide of the file extension.
Do you use FM 'SX_OBJECT_CONVERT_OTF_PDF' ?
The extension is put the it_mailpack-obj_name parameter of 'SO_NEW_DOCUMENT_ATT_SEND_API1'.
Best regards,
Erwan
2006 Oct 06 4:01 PM
Hi Erwan,
I'm not using the FM 'SX_OBJECT_CONVERT_OTF_PDF'.
Even if I change the extension to PDF, still the problem persists. The file is not opening and showing the same error status.
Regards,
Pritam
2006 Oct 06 4:05 PM
Ah Ok,
How does it work ?
For info, I retrieve the OTF table from the FM CLOSE_FORM then I convert my OTF to PDF using FM 'SX_OBJECT_CONVERT_OTF_PDF' then I attach and send my mail with 'SO_NEW_DOCUMENT_ATT_SEND_API1'.
Erwan
2006 Oct 06 4:07 PM
Check this document is useful:
&----
*& 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.
2006 Oct 06 4:17 PM
Hi Erwan,
I'm also following the same way. But I'm not using the FM 'SX_OBJECT_CONVERT_OTF_PDF' to convert the OTF into PDF. Do I need to use this FM before passing it to 'SO_NEW_DOCUMENT_ATT_SEND_API1'?
If yes, please send me the sample code.
Regards,
Pritam
2006 Oct 11 10:37 AM
Hi Erwan,
Thanks a Lot. I changed the OTF to PDF and then attached it to the mail. It working fine now.
Thanks to Prakash also for sending the sample codes.
Guys I was trying reward points to you. But its showing some error. I've tried several times. But its still not working. The procedure I'm following is to click on the radio buttons on the left below your name. Is there any other process to be followed?
Error Message:
Community Forums Error
Error:
Rewarding the message failed.
Regards,
Pritam