on 04-21-2010 10:40 AM
Hello Everyone,
My requirement is to Email an internal table as an Excel sheet. I had a look on SDN for quite a while and am giving up now. There are so many questions about exporting to Excel. But, I need to email the internal table as an excel sheet. Would anyone be able to help me to resolve this issue. I would greatly appreciate your help.
Regards,
Gopal.
Alternatively you can use the standard ABAP class cl_bcs (Business Communication services) to send the email with attachment. Attachment can be added using the below code-
CALL METHOD document->add_attachment
EXPORTING
i_attachment_type = ls_attachments-file_type
i_attachment_subject = ls_attachments-file_name
i_att_content_hex = ls_attachments-attachx[].
As excel file is a BINARY document, you need to pass the binary data. Refer to the my article below for more details:
http://divulgesap.com/blog.php?p=ODI=
Regards,
Ravikiran
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ravikiran,
Thanks a lot for your reply. I managed to get it working by using the above suggested FM. Now, I have another requirement, where I need to pass headings for the columns of the Excel sheet that I am emailing. Would you be able to suggest me of how to acheive this. i would greatly appreciate your help.
Regards,
Gopal.
Hi Gopal,
You can get the components in your internal table using the below code-
lo_struc_descr ?= cl_abap_typedescr=>describe_by_data( <fs_line> ).
lt_components = lo_struc_descr->get_components( ).
* Insert the component names in the start of the file
LOOP AT lt_components INTO ls_components.
IF lv_string IS INITIAL.
lv_string = ls_components-name.
ELSE.
CONCATENATE lv_string ls_components-name INTO lv_string
SEPARATED BY cl_abap_char_utilities=>horizontal_tab.
ENDIF.
ENDLOOP.
Here <fs_line> is a work area. Basically we are getting all the fields in the internal table and writing their names in the start of the file.
Hope it helps.
Regards,
Ravi
Hi,
Please follow these steps :
1. Get the data into an internal table.
2. Use this FM to convert the data into Xstring :
'SCMS_STRING_TO_XSTRING'
3. Finally attach the Xstring Format of the Excel with the method to send mail as an attachment:
cl_hrrcf_services_mail=>send_web_mail.
i hope it helps.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Saurav,
Thanks a lot for your reply. I tried to use the class "cl_hrrcf_services_mail=>send_web_mail". But, when I attach the attachment which is of type "XSTRING" to "PT_ATTA_HEX" which is of type "RCF_T_ATT4MAIL_HEX" it is giving a "type incompatible error" message. Could you please help me in resolving this error. I would greatly appreciate your help.
Regards,
Gopal.
User | Count |
---|---|
86 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.