Application Development and Automation 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: 
Read only

Multiple Excel sheets and email

Former Member
0 Likes
3,283

Hi All,

My requirement is to send multi sheets excel as attachment email to external id in Background.

Kindly help me in this .

My analysis what i found:

1. Multi Sheets excel can be created using OLE.

But OLE only works in Foreground.

2. Excel can be send using FM   'SO_NEW_DOCUMENT_ATT_SEND_API1'.

But i can send only single sheet excel.

Workaround which i found :

use XML but i can find flow i mean way to do so.

Kindly help me in this .

7 REPLIES 7
Read only

GrahamRobbo
SAP Mentor
SAP Mentor
0 Likes
1,927

Hi Mahesh,

this function module it just a simplified interface to the SAP Business Communications Services. BCS supports multiple attachments and a whole lot of other stuff that this function module interface does not.

Search for BCS in the forums, blogs and wiki and you will see how to call it.

Cheers

Graham Robbo

Read only

0 Likes
1,927

@ Graham Thanks for your quick response..

But my requirement is to send multiple sheet workbook as single attachment and not multiple attachment.. Hope you can help in this case also...

Read only

naimesh_patel
Active Contributor
0 Likes
1,927

As Graham suggested, you should use BCS as it easy to use compare to FM. Check the program BCS_EXAMPLE_7 to understand how you can create XLS and attach to email. Use the same logic more than once to create multiple attachments.

Regards,
Naimesh Patel

Read only

0 Likes
1,927

Thanks Naimesh.. but my requirement is to send multiple sheet workbook as single attachment and not multiple attachment.. any suggestion are welcome.. hope the confusion is solve...

Read only

Former Member
0 Likes
1,927

Hi Mahesh,

With FM 'SO_NEW_DOCUMENT_ATT_SEND_API1', you can send multiple excel files.

1.) Append data of all excel files in 1 internal table it_mailhex.

2.) Fill it_sopcklsti1 as follows:

lv_attach_no = 1.

  CLEAR wa_sopcklsti1.
  wa_sopcklsti1-transf_bin = 'X'.
  wa_sopcklsti1-head_start = 1.
  wa_sopcklsti1-head_num = 1.
  wa_sopcklsti1-body_start = lv_attach_no.

" it_excel_attach1 is first excel file data
  DESCRIBE TABLE it_excel_attach1 LINES wa_sopcklsti1-body_num.
  wa_sopcklsti1-doc_type = 'XLS'.
  wa_sopcklsti1-obj_name = 'FILE1'.
  wa_sopcklsti1-obj_descr = 'FILE1'.

  wa_sopcklsti1-doc_size = wa_sopcklsti1-body_num * 550.
  APPEND wa_sopcklsti1 TO it_sopcklsti1.

** " Describe the second attachment info for Excel file
** " Type of File : XLS

  lv_attach_no = lv_attach_no + wa_sopcklsti1-body_num.
  CLEAR wa_sopcklsti1.
  wa_sopcklsti1-transf_bin = 'X'.
  wa_sopcklsti1-head_start = 1.
  wa_sopcklsti1-head_num = 1.
  wa_sopcklsti1-body_start = lv_attach_no.


" it_excel_attach2 is second excel file data
  DESCRIBE TABLE it_excel_attach2 LINES wa_sopcklsti1-body_num.
  wa_sopcklsti1-doc_type = 'XLS'.
  wa_sopcklsti1-obj_name = 'FILE2'.

  wa_sopcklsti1-obj_descr = 'FILE2'.

  wa_sopcklsti1-doc_size = wa_sopcklsti1-body_num * 550.
  APPEND wa_sopcklsti1 TO it_sopcklsti1.

3.) CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
      document_data              = wa_doc_data
      put_in_outbox              = gc_x
      commit_work                = gc_x
    TABLES
      packing_list               = it_sopcklsti1
      contents_hex               = it_mailhex
      contents_txt               = it_message
      receivers                  = it_receivers.

Do let me know for any questions.

Read only

0 Likes
1,927

Hi,

Please check the below link. It has been explained clearly.

http://wiki.sdn.sap.com/wiki/display/Snippets/Sending+mail+with+attachment+using+Object+Oriented+App...

Best Wishes,

Bharath.

Read only

Former Member
0 Likes
1,927

@shaleen kansal .. Thanks for your response but my requirement is to send multilpe sheet workbook and not multiple wrokbook.. the code provided by you will be sueful when i want to send multiple workbook...

@ Bharath .... same is the code for multiple workbook