‎2009 Apr 21 6:01 PM
Hi,
I am trying to sand an excel attachment by email using
"SO_NEW_DOCUMENT_ATT_SEND_API1" FM from SAP 6.0. The file has been
transferred fine, but is going as an unrecognized format. Please give me
some suggestions regarding this.
using:
t_packing_list-doc_type = 'XLS'.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = w_doc_data
put_in_outbox = 'X'
commit_work = 'X'
IMPORTING
sent_to_all = w_sent_all
TABLES
packing_list = t_packing_list
contents_bin = t_attachment
contents_txt = it_message
receivers = t_receivers
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.
Thanks,
Goutham.
‎2009 Apr 21 6:04 PM
It appears that you are sending the document type in the internal table header rather than the table itself.
Try:
t_packing_list-doc_type = 'XLS'.
append t_packing_list.Rob
Oh yes - and welcome to SCN.
Edited by: Rob Burbank on Apr 21, 2009 1:05 PM
‎2009 Apr 21 6:29 PM
Yes Rob. I am appending the doc type to t_packing_list table.
DATA: t_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE
Create attachment notification
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 1.
t_packing_list-body_start = 1.
describe table t_attachment lines t_packing_list-body_num.
t_packing_list-doc_type = 'XLS'.
t_packing_list-obj_descr = ld_attdescription.
t_packing_list-obj_name = ld_attfilename.
t_packing_list-doc_size = t_packing_list-body_num * 255.
append t_packing_list.
Thanks.
‎2009 Apr 21 6:38 PM
w_doc_data-obj_langu = sy-langu.
w_doc_data-sensitivty = 'F'.
w_doc_data-proc_type = 'T'.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = w_doc_data
Welcome to SCN!!
‎2009 Apr 21 6:54 PM
Still the same after changing. Please let me know if I am missing some code.
Fill the document data and get size of attachment
CLEAR w_doc_data.
READ TABLE it_attach INDEX w_cnt.
w_doc_data-doc_size =
( w_cnt - 1 ) * 250 + STRLEN( it_attach ).
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle.
w_doc_data-sensitivty = 'F'.
w_doc_data-proc_type = 'T'.
CLEAR t_attachment.
REFRESH t_attachment.
t_attachment[] = it_attach[].
Describe the body of the message
CLEAR t_packing_list.
REFRESH t_packing_list.
t_packing_list-transf_bin = space.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
DESCRIBE TABLE it_message LINES t_packing_list-body_num.
t_packing_list-doc_type = 'RAW'.
APPEND t_packing_list.
Create attachment notification
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 1.
t_packing_list-body_start = 1.
DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
t_packing_list-doc_type = 'XLS'.
t_packing_list-obj_descr = ld_attdescription.
t_packing_list-obj_name = ld_attfilename.
t_packing_list-doc_size = t_packing_list-body_num * 255.
APPEND t_packing_list.
t_receivers-receiver = i_email-p_email.
t_receivers-rec_type = 'U'.
t_receivers-express = 'X'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
APPEND t_receivers.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
Thanks.
‎2009 Apr 21 6:59 PM
try
DESCRIBE TABLE it_message LINES t_packing_list-body_num.
t_packing_list-doc_type = 'RAW'.
APPEND t_packing_list.
Create attachment notification
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 1.
t_packing_list-body_start = 1.
DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
t_packing_list-doc_type = 'XLS'. ">>>>>>>>>>>> try changing to RAW
t_packing_list-obj_descr = ld_attdescription.
‎2009 Apr 21 8:03 PM
It is saving as text file if I change to 'RAW' format. I think the issue is the excel file attachment is sent as tab delimited file, because when I open the excel file and try to save it again on my had disk it is saving as Text (tab delimited) file. Wont the excel file automatically recognize tab delimited file?
I am using the below constants as separators.
constants:
con_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab,
con_cret TYPE c VALUE cl_abap_char_utilities=>cr_lf.
Thanks.