01-11-2008 2:29 PM
hai tell me how can we mail an output list or take printouts of output of a report.
01-11-2008 2:33 PM
Here is a sample program which does the same.
report zrich_0003 .
data: list type table of abaplist with header line.
data: htmllines type table of w3html with header line.
data: maildata like sodocchgi1.
data: mailtxt like solisti1 occurs 10 with header line.
data: mailrec like somlrec90 occurs 0 with header line.
start-of-selection.
Write the list
do 100 times.
write:/ sy-index, at 30 sy-index, at 50 sy-index.
enddo.
Save the list
call function 'SAVE_LIST'
tables
listobject = list
exceptions
list_index_invalid = 1
others = 2.
Convert to HTML
call function 'WWW_LIST_TO_HTML'
tables
html = htmllines.
perform build_text_message.
perform build_receivers.
perform send_mail_nodialog..
************************************************************************
Form BUILD_TEXT_MESSAGE
************************************************************************
form build_text_message.
maildata-obj_name = 'TEST'.
maildata-obj_descr = 'Test Subject'.
loop at htmllines.
mailtxt = htmllines.
append mailtxt.
endloop.
endform.
************************************************************************
Form BUILD_RECEIVERS
************************************************************************
form build_receivers.
mailrec-receiver = 'you@yourcompany.com'.
mailrec-rec_type = 'U'.
append mailrec.
endform.
************************************************************************
Form SEND_MAIL_NODIALOG
************************************************************************
form send_mail_nodialog.
call function 'SO_NEW_DOCUMENT_SEND_API1'
exporting
document_data = maildata
document_type = 'HTM'
put_in_outbox = 'X'
tables
object_header = mailtxt
object_content = mailtxt
receivers = mailrec
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.
endif.
endform.
Code Formatted by: Alvaro Tejada Galindo on Jan 11, 2008 3:06 PM
01-11-2008 8:09 PM
At least you could say that the code belongs to Rich Heilman...That's what I do when I post someone else code...
Greetings,
Blag.
01-11-2008 2:42 PM
to send output list to spool....proceed this way....
Constants:lc_pri_params-pdest TYPE pri_params-pdest VALUE 'LOCL'.
IF NOT it_messtab[] IS INITIAL .
*FM to get the parameters to write into a spool
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
destination = lc_pri_params-pdest
line_size = 220
layout = 'X_65_255'
release = ' '
mode = 'CURRENT'
no_dialog = 'X'
IMPORTING
out_parameters = l_params
valid = l_valid
EXCEPTIONS
archive_info_not_found = 1
invalid_print_params = 2
invalid_archive_params = 3
OTHERS = 4.
NEW-PAGE PRINT ON PARAMETERS l_params NO DIALOG.
*Write Error Report into Spool
IF NOT it_messtab[] IS INITIAL.
WRITE:/ 'ERROR REPORT'(005).
LOOP AT it_messtab.
WRITE:/ it_messtab.
ENDLOOP.
ENDIF.
NEW-PAGE PRINT OFF.
ENDIF.
Regards
Vasu
01-11-2008 2:44 PM
Hi Sudheer,
Try this FM if it is an ALV report.
ALV_TREE_PRINT_SERVER
<REMOVED BY MODERATOR>
Edited by: Alvaro Tejada Galindo on Jan 11, 2008 3:09 PM