2007 Sep 26 6:06 AM
Hi experts.
Can anyone tell me how to convert a spool data in to excel format and the send it through e-mail......
We have a function module for converting spool data to pdf and send it through mail ie FM CONVERT_ABAPSPOOLJOB_2_PDF,
but is there any FM for Excel ....
Kindly help me.....
Thanks
Naveen
2007 Dec 20 6:40 AM
2007 Dec 21 9:06 PM
you can send a file as an exel attachment in mail,
step 1:
send file data to an internal table.
step 2:
loop through the internal table(itab).
concatinate itab-field1
abap_char_utilities=>horizontal tab
itab-field2
abap_char_utilities=>horizontal tab
....
......
........
abap_char_utilities=>vertical tab
into t_attachment-line
append t_attachment
step 3:
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 ) * 255 + STRLEN( 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-doc_size = t_packing_list-body_num * 255.
t_packing_list-obj_name = 'Attachment'.
t_packing_list-obj_descr = 'mail xls'
APPEND t_packing_list.
Add the recipients email address
CLEAR t_receivers.
REFRESH t_receivers.
MOVE: mail id TO t_receivers-receiver,
'U' TO t_receivers-rec_type,
APPEND t_receivers.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = w_doc_data
put_in_outbox = 'X'
commit_work = 'X'
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.
check the FM and creat the internal table types
by this way you can send excel as an attachment
but problem in sending EXCEL attachment is if the data crosses the limit of excle file the file will not open.