Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Mail excel sheet

Former Member
0 Kudos
184

Hi,

I create an excel sheet using the following code:

CREATE OBJECT excel_app 'EXCEL.APPLICATION' NO FLUSH.

CALL METHOD OF excel_app 'Workbooks' = excel_workbook NO FLUSH.

CALL METHOD OF excel_workbook 'Add' = excel_sheet NO FLUSH.

The parameters excel_app, excel_workbook and excel_sheet are OLE2_OBJECT objects.

Further more addtion calls to fill the sheet are done.

To display the sheet the following code:

SET PROPERTY OF excel_app 'Visible' = 1 no flush.

This is working and on the client the excel sheet is displayed.

The change I need to make is not to display the excel sheet but mail that sheet.

I have searched a lot here on sdn, google etc but found nothing how to do that.

One option would be to save the sheet on a file system and add that as attachment but in my opinion that's not the solution.

What would be an other option?

TIA,

Patrick Willems

1 ACCEPTED SOLUTION

Former Member
0 Kudos
98

Please use the attachment concept, while sending email.

You can achieve this through the class method.

7 REPLIES 7

Former Member
0 Kudos
99

Please use the attachment concept, while sending email.

You can achieve this through the class method.

0 Kudos
98

Hi,

What is the attachment concept for sending mail?

Do you have information / documentation / OO objects / Classes for this?

Regards,

Patrick Willems

0 Kudos
98

Hello,

the FM SO_NEW_DOCUMENT_ATT_SEND_API1 has worked fine for me. I could send an example if needed.

Best Regards,

Diana Abu-Gosh

0 Kudos
98

Search the forum or blogs/wikis for CL_BCS and XLS or Excel. There should be many examples available for both XLS and CSV attachment processing. Attaching Excel files in XLS format is very easy with the CL_BCS class. Don't use SO_NEW_DOCUMENT_ATT_SEND_API1 - it's been obsolete for a long time above v46.

0 Kudos
98

Hallo Brad,

I tried to follow your advise, as I was using SO_NEW_DOCUMENT_ATT_SEND_API1 and it worked fine for me, but I wanted to use CL_BCS methods.

My problem is that I need to attach an axcel file formatted with xml, but if I use the add_attachment method the result is an empty file, even if with the SO_NEW_DOCUMENT_ATT_SEND_API1 I was able to send the file.

here is an extracr of the code I am using

CALL METHOD w_document->add_attachment "w_document TYPE REF TO cl_document_bcs

EXPORTING

i_attachment_type = 'xls'

i_attachment_size = w_size "DESCRIBE TABLE t_solix LINES w_size.

i_attachment_subject = 'file.xls'

i_att_content_hex = t_solix[]. "t_solix TYPE solix_tab.

CALL METHOD w_send_req->set_document( w_document ). "w_send_req TYPE REF TO cl_bcs,

Is there anything wrong?

Thanks in advance for any help.

Edited by: Moody973 on Jun 6, 2011 5:33 PM

Former Member
0 Kudos
98

Hi Patrick

As you are using OLE objects for creating the excel file, you cannot mail the spreadsheet unless you download and upload again, and then use BCS class methods.

Only option i can think of is is to use the statement

 Application.Dialogs(xlDialogSendMail).Show 

from your workbook, this will open your outlook email and attach the file you have opened. But again there is lot of drawback with this approach, this will work only for MS Outlook, MS outlook should be installed on the client etc.

Alternatively if your excel is simple one without much formatting and other functions/macros, i would suggest to create a csv file and mail it from the program.

Note : Might be aware of the performance, when using the OLE objects.

Regards

Ranganath

monika_dhumal
Participant
0 Kudos
98

Hi,

Check this out.

http://wiki.sdn.sap.com/wiki/display/ABAP/HowtowriteanABAPProgramtoplaceanExcelfileinapathandsenditasan+Attachment