12-03-2007 12:37 PM
Hello All,
I want to send a report via e-mail.
What should I do for that?
Please help me out...
Regards,
Ravi Khattar.
12-03-2007 12:40 PM
Hi,
Please check the below code....
data: t_objpack like sopcklsti1 occurs 1 with header line,
t_objhead like solisti1 occurs 1 with header line,
t_objtxt like solisti1 occurs 0 with header line,
t_objbin like solisti1 occurs 1 with header line,
t_reclist like somlreci1 occurs 1 with header line,
t_lobj like abaplist occurs 0 with header line,
t_listobj like abaplist occurs 1 with header line.
data: v_tab_line1 type i,
v_tab_line2 type i,
v_docsize type i,
v_len type i,
v_line(1250) type c,
v_subj(132) type c,
v_cr(1) type x value '0D',
v_linefd(2) type x value '0D0A',
v_docdata like sodocchgi1.
clear: t_objpack[], t_objhead[], t_objtxt[], t_reclist[], t_listobj[].
concatenate 'This email is generated from a SAP' sy-sysid '-'
sy-mandt '- batch environment.' into t_objtxt separated by ' '.
append t_objtxt.
t_objtxt = 'Please do not respond to this email.'. append t_objtxt.
v_docdata-obj_name = 'SAMPLE_TEST'.
concatenate 'Sales Order Status Attachment -' sy-datum '-' sy-uzeit
into v_subj separated by ' '.
v_docdata-obj_descr = v_subj.
describe table t_objtxt lines v_tab_line1.
read table t_objtxt index v_tab_line1.
v_docdata-doc_size = ( v_tab_line1 - 1 ) * 255 + strlen( t_objtxt ).
t_objpack-head_start = 1.
t_objpack-head_num = 1.
t_objpack-body_start = 1.
t_objpack-body_num = v_tab_line1.
t_objpack-doc_type = 'RAW'.
append t_objpack.
clear v_line.
if p_type = '1'.
loop at t_list.
concatenate v_line t_list v_linefd into v_line.
v_len = strlen( v_line ).
do 4 times.
if v_len ge 255.
if v_line+254(1) = v_cr.
v_line255 = v_line254.
v_line+254(1) = ' '.
endif.
t_objtxt = v_line(255).
v_line = v_line+255.
v_len = v_len - 255.
append t_objtxt.
else.
exit.
endif.
enddo.
endloop.
if v_line ne ' '.
t_objtxt = v_line(255).
append t_objtxt.
endif.
describe table t_objtxt lines v_tab_line2.
t_objpack-doc_size = ( v_tab_line2 - v_tab_line1 ) * 255.
t_objpack-body_start = v_tab_line1 + 1.
t_objpack-transf_bin = ' '.
t_objpack-doc_type = 'TXT'.
else.
t_objbin[] = html[].
describe table t_objbin lines v_tab_line2.
t_objpack-doc_size = v_tab_line2 * 255.
t_objpack-body_start = 1.
t_objpack-transf_bin = 'X'.
t_objpack-doc_type = 'HTM'.
endif.
t_objpack-head_start = 1.
t_objpack-head_num = 1.
t_objpack-body_num = v_tab_line2.
t_objpack-obj_name = 'SAMPLE_TEST'.
t_objpack-obj_descr = 'Test'.
append t_objpack.
loop at s_email.
t_reclist-receiver = s_email-low.
t_reclist-rec_type = 'U'.
append t_reclist.
endloop.
t_reclist-receiver = sy-uname.
t_reclist-rec_type = 'B'.
append t_reclist.
call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = v_docdata
put_in_outbox = ' '
TABLES
packing_list = t_objpack
object_header = t_objhead
contents_bin = t_objbin
contents_txt = t_objtxt
receivers = t_reclist.
if sy-subrc = 0.
endif.
Cheers,
Bujji
12-03-2007 12:40 PM
Hi Ravi,
Plz use this FM:
sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
-pesi
12-03-2007 12:49 PM