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: 

Creating an excel file with multiple sheets and send it as an attachment

Former Member
0 Kudos

Hi Friends,

My Requirement is i have a three internal table with contain data , that data send mail to the particular email id's through report with excel attachment. This Excel Work book contain three sheet with three internal table data. I have report that generate Excel with multiple sheet but it open dynamically when i execute and doing save manually how it is saved automatically and how it send to with attachment.

11 REPLIES 11

Former Member
0 Kudos

The best method would be save the excel sheet with three sheets in .html format. Go through the HTML code generated, the same code can be used to create the table of data to be sent through the mail sending FM/Method and the file type needs to be set as excel. I have used this method once. There are documents available over the net. Use key words OLE ABAP EXCEL MULTIPLE to search for the document.

Thanks,

Saravanan R

Clemenss
Active Contributor
0 Kudos

Hi Santu,

using [Desktop Office Integration|http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCCIOFFI/BCCIOFFI.pdf] we can save the excel to a local file, upload it in binary format and attach it to a BCS mail object.


CALL METHOD document->create_document
  EXPORTING 
    open_inplace = open_inplace
    create_view_data = create_view_data
    onsave_macro = onsave_macro
    startup_macro = startup_macro
    document_title = document_title
    no_flush = no_flush
  IMPORTING error = error
    retcode = retcode.
...
CALL METHOD document->save_as
  EXPORTING 
    file_name = file_name
    prompt_user = prompt_user
    no_flush = no_flush
    IMPORTING error = error
    retcode = retcode.
...

  CALL METHOD cl_gui_frontend_services=>gui_upload
    EXPORTING
      filename                = file_name
      filetype                = 'BIN'
    IMPORTING
      filelength              = lf_filelength
    CHANGING
      data_tab                = lt_datatab
    EXCEPTIONS
      OTHERS                  = 1.
...
 data: lo_document TYPE REF TO cl_document_bcs.
     lo_document = cl_document_bcs=>create_document(
...
  TRY.
      CALL METHOD document->add_attachment
        EXPORTING
          i_attachment_type    = att_type
          i_att_content_text   =  lt_datatab
          i_attachment_size    = i_lenght
          i_attachment_subject = subject.
    CATCH cx_bcs INTO bcs_exception.
*Error Message
  ENDTRY.

...

Just roughly. Search SCN and complete.

Regards,

Clemens

Former Member
0 Kudos

Hi Clemens,

Thanks for replying

Please give me a sample report My requirement is The program will run in background and will send an email with attached excel sheet with multiple worksheets to specified email addresses.

0 Kudos

Hi Santu,

sorry, I am nor a Sample developer. But I'm convinced you can find and combine solutions on SCN and elsewhere.

Regards,

Clemens

0 Kudos

This message was moderated.

0 Kudos

Hi,

Clemens

Thanks for your reply.

I done it different way using XML.

Former Member
0 Kudos

Problem Solved. I done it Using XML for sending multiple Excel attachment.

0 Kudos

Hi Santu,

Could you please help me with Sample code.

I have a same kind of requirement

Regards

0 Kudos

could you just give me a sample code....I have a same requirements.

0 Kudos

Could you please share the code.

Former Member
0 Kudos

This message was moderated.