on 11-27-2007 12:58 PM
Hi,
I had a requirement like sending smartform o/p as PDF to multiple email-id's.
I had used the FM's CONVERT_OTF and SO_NEW_DOCUMENT_ATT_SEND_API1 Function module's.
Now I am able to receive the emails but unable to open the PDF document It is saying that the PDF was not decoded properly. Kindly help me out. I had also tried it using the GUI_DOWNLOAD after the CONVERT_OTF Function module. and was able to open the PDF format.
Kindly help me out.
Thanks & Regards,
Sridhar.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sridhar
Look part of my code.
<b> First u need to obtain the OTF Table using :</b>
st_control_parameters-no_dialog = 'X'.
st_control_parameters-getotf = 'X'.
call function funcion --> Name Smartforms FM
exporting
control_parameters = st_control_parameters
respon = respon
titulo = titulo
cantid = reg
importing
document_output_info = st_document_output_info
job_output_info = st_job_output_info
job_output_options = st_job_output_options
tables
it_val = it_cons
exceptions
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
others = 5.
<b>Second: CONVERT TO OTF TO PDF using fm :</b>
call function 'CONVERT_OTF_2_PDF'
importing
bin_filesize = v_bin_filesize
tables
otf = st_job_output_info-otfdata
doctab_archive = it_docs
lines = it_lines
exceptions
err_conv_not_possible = 1
err_otf_mc_noendmarker = 2
others = 3.
<b>Third: u need convert the otf format to BIN format using: </b>
it_output[] = st_job_output_info-otfdata[].
Attachment
refresh:
i_reclist,
i_objtxt,
i_objbin,
i_objpack.
*****
Move OTF code to structure SOLI form email
clear i_otf. refresh i_otf.
loop at p_output.
i_otf-line = p_output.
append i_otf.
endloop.
clear wa_objhead.
call function 'SX_OBJECT_CONVERT_OTF_PDF'
exporting
format_src = 'OTF'
format_dst = 'PDF'
devtype = 'PRINTER'
FUNCPARA =
len_in = '1234'
IMPORTING
LEN_OUT =
tables
content_in = i_otf
content_out = i_objbin
exceptions
err_conv_failed = 1
others = 2.
u can to pass the table <b>I_objbin</b> directly to Fm SO_NEW_DOCUMENT_ATT_SEND_API1 for send the email
Regards
Gregory
Hi,
I am receivng the email but unable to open the PDF attachement in email.
I am using the AFS system here i.e Apparel Footwear system, in which i am able to see the different parameteres for the FM's CONVERT TO OTF TO PDF and SX_OBJECT_CONVERT_OTF_PD not the ones you had send me in ur email.
I am also sending my code below.
CALL FUNCTION g_fnam
EXPORTING
archive_index = toa_dara
ARCHIVE_INDEX_TAB =
archive_parameters = arc_params
control_parameters = ls_control_param "Smart Forms: Control structure
MAIL_APPL_OBJ =
mail_recipient = ls_recipient "Recipient Object ID
mail_sender = ls_sender "Sender Object ID
output_options = ls_composer_param "Smart Forms: Composer structure
user_settings = ' '
g_ship_to = g_ship_to "SHIP-TO
g_bill_to = g_bill_to "BILL-TO
wa_vbrk = wa_vbrk "Billing Document: Header Data
wa_adrc1 = wa_adrc1
wa_adrc2 = wa_adrc2
wa_vttk = wa_vttk "Shipment Header
wa_likp = wa_likp "SD Document: Delivery Header Data
g_name1 = g_name1 "NAME1
g_country = g_country
g_country1 = g_country1 "COUNTRY NAME
g_country2 = g_country2
*--->Start of changes by srperuma on 22nd november 2007 0007
IMPORTING
DOCUMENT_OUTPUT_INFO =
job_output_info = wa_return
*--->End of changes by srperuma on 22nd november 2007 0007.
JOB_OUTPUT_OPTIONS =
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5
.
*--->Start of changes by srperuma on 22nd november 2007 0007.
REFRESH t_otf[].
t_otf[] = wa_return-otfdata[].
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
ARCHIVE_INDEX = ' '
COPYNUMBER = 0
ASCII_BIDI_VIS2LOG = ' '
PDF_DELETE_OTFTAB = ' '
IMPORTING
bin_filesize = v_len_in
BIN_FILE =
TABLES
otf = t_otf
lines = t_tline
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 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.
DATA : file_size TYPE i.
*
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
bin_filesize = v_len_in
filename = 'C:\Documents and Settings\srperuma\Desktop\test.pdf'
filetype = 'BIN'
APPEND = ' '
WRITE_FIELD_SEPARATOR = ' '
HEADER = '00'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
CONFIRM_OVERWRITE = ' '
NO_AUTH_CHECK = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
WRITE_BOM = ' '
TRUNC_TRAILING_BLANKS_EOL = 'X'
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
WRITE_LF_AFTER_LAST_LINE = ABAP_TRUE
IMPORTING
filelength = file_size
TABLES
data_tab = t_tline[]
FIELDNAMES =
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 ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT t_tline.
TRANSLATE t_tline USING ' ~'.
CONCATENATE wa_buffer t_tline INTO wa_buffer.
ENDLOOP.
TRANSLATE wa_buffer USING '~ '.
DO.
t_record = wa_buffer.
APPEND t_record.
SHIFT wa_buffer LEFT BY 255 PLACES.
IF wa_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
REFRESH : t_reclist[],
t_objtxt[],
t_objbin[],
t_objpack[].
CLEAR : wa_objhead.
t_objbin[] = t_record[].
*Create message body title and description
t_objtxt = 'Test with pdf-attachment'.
APPEND t_objtxt.
DESCRIBE TABLE t_objbin LINES v_lines_bin.
DESCRIBE TABLE t_objtxt LINES v_lines_txt.
READ TABLE t_objtxt INDEX v_lines_txt.
*Fill the document data.
wa_doc_chng-obj_langu = sy-langu.
wa_doc_chng-expiry_dat = sy-datum + 10.
wa_doc_chng-obj_name = 'EMAIL'.
wa_doc_chng-obj_descr = 'TEST'.
wa_doc_chng-sensitivty = 'F'.
wa_doc_chng-doc_size = v_lines_txt * 255.
*Main Text
CLEAR : t_objpack-transf_bin.
t_objpack-head_start = 1.
t_objpack-head_num = 0.
t_objpack-body_start = 1.
t_objpack-body_num = v_lines_txt.
t_objpack-doc_type = 'RAW'.
APPEND t_objpack.
CLEAR : t_objpack.
READ TABLE t_objbin INDEX v_lines_bin.
*Pdf attachment.
t_objpack-transf_bin = 'X'.
t_objpack-head_start = 1.
t_objpack-head_num = 1.
t_objpack-body_start = 1.
t_objpack-body_num = v_lines_bin.
t_objpack-doc_type = 'PDF'.
t_objpack-obj_name = 'EMAIL'.
t_objpack-obj_descr = 'TEST'.
t_objpack-doc_size = v_lines_bin * 255.
t_objpack-obj_langu = sy-langu.
APPEND t_objpack.
CLEAR : t_objpack.
LOOP AT t_emails.
t_reclist-receiver = t_emails-smtp_addr. "'sriperum@in.ibm.com'.
t_reclist-express = 'X'.
t_reclist-rec_type = 'U'.
t_reclist-com_type = 'INT'.
t_reclist-notif_del = 'X'.
t_reclist-notif_ndel = 'X'.
APPEND t_reclist.
ENDLOOP.
DATA : w_sent_all(1) TYPE c.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = wa_doc_chng
put_in_outbox = 'X'
commit_work = 'X'
IMPORTING
sent_to_all = w_sent_all
NEW_OBJECT_ID =
TABLES
packing_list = t_objpack
object_header = wa_objhead
contents_bin = t_objbin
contents_txt = t_objtxt
CONTENTS_HEX =
OBJECT_PARA =
OBJECT_PARB =
receivers = t_reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.
COMMIT WORK.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*
User | Count |
---|---|
72 | |
8 | |
8 | |
6 | |
6 | |
6 | |
5 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.