‎2008 Mar 07 5:15 AM
Hi all,
I am using function module SO_DOCUMENT_SEND_API1 to send attachment on user's sap id. But when I attach a text file it shows the attachment as follows:-
hello this is test email.
hello this is test email.
hello this is test email.
hello this is test email.
hello this is test email.
hello this is test email.
It starts giving space before starting the new line. Can u pls suggest what should I do.
Thanks in advance.
Ritu
‎2008 Mar 07 5:18 AM
hi
check this code...
*Check if mail sending required...
if p_mail = c_x.
if not it_error_desc[] is initial.
*Document data to be passed to function module
wa_document_data-obj_langu = sy-langu.
wa_document_data-obj_name = text-023.
wa_document_data-obj_descr = text-024.
wa_document_data-sensitivty = c_o.
it_objtxt = text-061.
append it_objtxt.
it_objtxt = text-062.
append it_objtxt.
it_objtxt = text-063.
append it_objtxt.
it_objtxt = sy-spono.
append it_objtxt.
describe table it_objtxt lines v_tablines.
read table it_objtxt index v_tablines.
wa_document_data-doc_size = ( v_tablines - 1 ) * 255 + strlen(
it_objtxt ).
clear it_packing_list-transf_bin.
it_packing_list-head_start = 1.
it_packing_list-head_num = 0.
it_packing_list-body_start = 1.
it_packing_list-body_num = v_tablines.
it_packing_list-doc_type = text-020.
append it_packing_list.
*ATTACHMENT DATA
clear wa_objbin.
refresh it_objbin.
constants:
con_tab type c value cl_abap_char_utilities=>horizontal_tab,
con_cret type c value cl_abap_char_utilities=>cr_lf.
"con_tab Horizontal TAB
"con_cret END OF LINE
clear wa_error_desc.
sort it_error_desc by customer.
concatenate text-051 text-066 text-064
into str separated by con_tab.
concatenate con_cret str into str.
wa_objbin = str.
append wa_objbin to it_objbin.
loop at it_error_desc into wa_error_desc.
concatenate wa_error_desc-customer wa_error_desc-field
wa_error_desc-desc into str separated by con_tab.
concatenate con_cret str into str.
wa_objbin = str.
append wa_objbin to it_objbin.
endloop.
*Packing Data in a table
it_packing_list-transf_bin = c_x.
it_packing_list-head_start = c_1.
it_packing_list-head_num = c_0.
it_packing_list-body_start = c_1.
describe table it_objbin lines it_packing_list-body_num .
read table it_objbin index v_tablines.
it_packing_list-doc_size = ( v_tablines - 1 ) * 255 + strlen( it_objbin
).
it_packing_list-body_num = v_tablines.
it_packing_list-doc_type = text-067.
it_packing_list-obj_name = text-021.
it_packing_list-obj_descr = text-022.
it_packing_list-obj_langu = sy-langu.
append it_packing_list.
*Receivers Information
it_receivers-receiver = p_rec.
*if receiver is a list
if p_list = 'X'.
it_receivers-rec_type = c_c.
else. "else to single user
it_receivers-rec_type = c_u.
endif.
it_receivers-com_type = c_int.
it_receivers-notif_del = c_x.
it_receivers-notif_ndel = c_x.
append it_receivers.
************************************************************************
*FM To Send E Mail Through SAP *
************************************************************************
call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
exporting
document_data = wa_document_data
put_in_outbox = c_x
commit_work = c_x
IMPORTING
SENT_TO_ALL =
NEW_OBJECT_ID =
tables
packing_list = it_packing_list
OBJECT_HEADER =
contents_bin = it_objbin
contents_txt = it_objtxt
CONTENTS_HEX =
OBJECT_PARA =
OBJECT_PARB =
receivers = it_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
.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
else .
clear p_mail.
message s055 with text-081.
endif.
else.
message e044 with text-080.
endif.
clear p_mail.
endif.
Reward if helpful,
Gaurav J.