Professional Documents
Culture Documents
Automatic Sending of ALV Output by Email - SAP Community
Automatic Sending of ALV Output by Email - SAP Community
Community
Welcome Learners!
Find out more
Join the new SAP BTP Learning group for guidance
and support to achieve your learnings goals.
Former Member
Oct 23, 2008 at 07:58 AM
Dear all,
I am currently facing a problem with the automatic sending of the output of an report by Email. The batchjob
which executes the reports works fine as well as also the Email is send. The only problem is, that the attachment
of the Email is a HTML File and not an Excel .XLS File. Is there a way to change it in the general setup of the user
settings (e.g.: Default Output parameters?). If not, what would be the possibilities?
Best regards
Maik
Assigned Tags
ABAP Development
https://answers.sap.com/questions/4963651/automatic-sending-of-alv-output-by-email.html 1/9
25/11/21 09.56 Automatic sending of ALV Output by Email | SAP Community
Similar Questions
Report output as an email attachment
Former Member Nov 23, 2019
Coffee Corner
Join the new Coffee Corner Discussion Group.
2 Answers
Former Member
Oct 23, 2008 at 08:00 AM
Hi,
0
Please visit this thread
how-to-send-alv-output-by-email
Regards
Jana
https://answers.sap.com/questions/4963651/automatic-sending-of-alv-output-by-email.html 2/9
25/11/21 09.56 Automatic sending of ALV Output by Email | SAP Community
Former Member
Oct 23, 2008 at 08:03 AM
TABLES: ekko.
DEFAULT 'xyz'.
END OF t_ekpo.
ebeln(10) TYPE c,
netwr(13) TYPE c,
aedat(8) TYPE c,
matnr(18) TYPE c,
END OF t_charekpo.
w_cnt TYPE i,
w_sent_all(1) TYPE c,
************************************************************************
*START_OF_SELECTION
START OF SELECTION
https://answers.sap.com/questions/4963651/automatic-sending-of-alv-output-by-email.html 3/9
25/11/21 09.56 Automatic sending of ALV Output by Email | SAP Community
START-OF-SELECTION.
PERFORM data_retrieval.
PERFORM build_xls_data_table.
************************************************************************
*END-OF-SELECTION
END-OF-SELECTION.
perform populate_email_message_body.
PERFORM send_file_as_email_attachment
tables it_message
it_attach
using p_email
'TXT'
'filename'
' '
' '
' '
changing gd_error
gd_reciever.
PERFORM initiate_mail_execute_program.
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*----------------------------------------------------------------------*
FORM data_retrieval.
UP TO 10 ROWS
FROM ekpo
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*
https://answers.sap.com/questions/4963651/automatic-sending-of-alv-output-by-email.html
* 4/9
25/11/21 09.56 Automatic sending of ALV Output by Email | SAP Community
*----------------------------------------------------------------------*
FORM build_xls_data_table.
*If you have Unicode check active in program attributes thnen you will
constants:
APPEND it_attach.
wa_charekpo-ebeln = wa_ekpo-ebeln .
wa_charekpo-netwr = wa_ekpo-netwr .
wa_charekpo-aedat = wa_ekpo-aedat .
wa_charekpo-matnr = wa_ekpo-matnr .
wa_charekpo-aedat wa_charekpo-matnr
APPEND it_attach.
ENDLOOP.
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
* Send email
*----------------------------------------------------------------------*
pit_attach
using p_email
p_mtitle
p_format
p_filename
p_attdescription
p_sender_address
p_sender_addres_type
changing p_error
p_reciever.
https://answers.sap.com/questions/4963651/automatic-sending-of-alv-output-by-email.html 5/9
25/11/21 09.56 Automatic sending of ALV Output by Email | SAP Community
ld_email = p_email.
ld_mtitle = p_mtitle.
ld_format = p_format.
ld_attdescription = p_attdescription.
ld_attfilename = p_filename.
ld_sender_address = p_sender_address.
ld_sender_address_type = p_sender_addres_type.
w_doc_data-doc_size = 1.
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle .
w_doc_data-sensitivty = 'F'.
CLEAR w_doc_data.
w_doc_data-doc_size =
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle.
w_doc_data-sensitivty = 'F'.
CLEAR t_attachment.
REFRESH t_attachment.
t_attachment[] = pit_attach[].
CLEAR t_packing_list.
REFRESH t_packing_list.
t_packing_list-transf_bin = space.
t_packing_list-head_start = 1.
t ki li t h d 0
https://answers.sap.com/questions/4963651/automatic-sending-of-alv-output-by-email.html 6/9
25/11/21 09.56 Automatic sending of ALV Output by Email | SAP Community
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
t_packing_list-doc_type = 'RAW'.
APPEND t_packing_list.
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 1.
t_packing_list-body_start = 1.
t_packing_list-doc_type = ld_format.
t_packing_list-obj_descr = ld_attdescription.
t_packing_list-obj_name = ld_attfilename.
APPEND t_packing_list.
CLEAR t_receivers.
REFRESH t_receivers.
t_receivers-receiver = ld_email.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
APPEND t_receivers.
EXPORTING
document_data = w_doc_data
put_in_outbox = 'X'
sender_address = ld_sender_address
sender_address_type = ld_sender_address_type
commit_work = 'X'
IMPORTING
sent_to_all = w_sent_all
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
6
https://answers.sap.com/questions/4963651/automatic-sending-of-alv-output-by-email.html 7/9
25/11/21 09.56 Automatic sending of ALV Output by Email | SAP Community
x_error = 6
enqueue_error = 7
OTHERS = 8.
ld_error = sy-subrc.
LOOP AT t_receivers.
ld_receiver = t_receivers-retrn_code.
ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*----------------------------------------------------------------------*
FORM initiate_mail_execute_program.
WAIT UP TO 2 SECONDS.
AND RETURN.
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*----------------------------------------------------------------------*
form populate_email_message_body.
REFRESH it_message.
APPEND it_message.
Before answering
You should only submit an answer when you are proposing a solution to the poster's problem. If you
want the poster to clarify the question or provide more information please leave a comment instead
https://answers.sap.com/questions/4963651/automatic-sending-of-alv-output-by-email.html 8/9
25/11/21 09.56 Automatic sending of ALV Output by Email | SAP Community
want the poster to clarify the question or provide more information, please leave a comment instead,
requesting additional details. When answering, please include specifics, such as step-by-step
instructions, context for the solution, and links to useful resources. Also, please make sure that you
answer complies with our Rules of Engagement.
Rules of Engagement
Please provide a distinct answer and use the comment option for clarifying purposes.
10 characters required.
Find us on
Newsletter Support
https://answers.sap.com/questions/4963651/automatic-sending-of-alv-output-by-email.html 9/9