‎2005 Nov 20 1:34 PM
Hi !
I want to send report output as attached html file to email.
i use the function SUBMIT y_program AND RETURN
EXPORTING LIST TO MEMORY .
( y_program is my report that create the output)
then i use function 'CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = itab
EXCEPTIONS
not_found = 1.
to read the output result.
then i use CALL FUNCTION 'WWW_HTML_FROM_LISTOBJECT'
EXPORTING
REPORT_NAME =
template_name = 'WEBREPORTING_REPORT'
TABLES
html = html_tab
listobject = itab.
to convert the output to html file.
at last i use the function :
doc_chng-obj_name = 'NAMEFILE'.
doc_chng-obj_descr = 'TITLE MAIL'.
CLEAR objtxt.
objtxt = 'This e-mail was sent from an automated system...'.
APPEND objtxt.
CLEAR objtxt.
objtxt = 'Do not reply to this message.'.
APPEND objtxt.
CLEAR objtxt.
CONCATENATE 'Please open the attachment to view the spool output from
*job:'(014)
jselect-jobname
INTO objtxt
SEPARATED BY space.
APPEND objtxt.
objtxt = 'Please open the attachment to view the
spool output from job.'.
APPEND objtxt.
*name of the file
CONCATENATE g_name htm_ext
INTO objhead.
APPEND objhead.
****
DESCRIBE TABLE objtxt LINES tab_lines.
READ TABLE objtxt INDEX tab_lines.
doc_chng-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
CLEAR objpack-transf_bin.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'RAW'.
APPEND objpack.
Creation of the entry for the compressed attachment
DESCRIBE TABLE html_tab LINES tab_lines.
objpack-transf_bin = 'X'.
objpack-head_start = 1.
objpack-head_num = 1.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = htm_type. " ?? 'HTML' .
objpack-obj_name = g_name.
CONCATENATE text-019 jselect-jobname
INTO objpack-obj_descr
SEPARATED BY space.
objpack-obj_descr = 'DECRIPTION OBJ 2' .
objpack-doc_size = tab_lines * 255.
APPEND objpack.
*
.
l_sap_user = 'my_user'.
inserting the e-mail parameters **
CLEAR l_wa_recv.
l_wa_recv-receiver = l_sap_user .
l_wa_recv-express = 'X'.
l_wa_recv-rec_type = 'B'.
APPEND l_wa_recv TO reclist.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = doc_chng " mail header
put_in_outbox = ' '
commit_work = 'X'
TABLES
packing_list = objpack
object_header = objhead " name of attachement
contents_bin = html_tab " html table
contents_txt = objtxt " contenu of mail
receivers = reclist " destination
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.
CASE sy-subrc.
WHEN 0.
LOOP AT reclist.
MESSAGE i007(ysd) . " 007
ENDLOOP.
WHEN 1.
un fortunately i get in the browser a garbage file.
( file contains '#####' )
please tell me what's the problem why do i get a garbage !
is the problem in parametrs of the 'SO_NEW_DOCUMENT_ATT_SEND_API1' function ?
if yes how to fix it ?
‎2005 Nov 21 5:41 AM
i faced similar problem with PDF file.
i just changed doc_typ = 'PDF'.
Did you tried HTML.
regards
surjit
‎2005 Nov 21 5:41 AM
i faced similar problem with PDF file.
i just changed doc_typ = 'PDF'.
Did you tried HTML.
regards
surjit
‎2005 Nov 21 9:15 AM
HI,
Check out this link to send an xls file as attachemtn to a mail id:
http://www.sapdevelopment.co.uk/reporting/email/attachhome.htm
Best Regards,
Anjali