2012 Mar 17 8:39 AM
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 .
2012 Mar 18 9:12 PM
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
2012 Apr 09 7:03 AM
@ 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...
2012 Mar 19 9:34 PM
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
2012 Apr 09 7:01 AM
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...
2012 Mar 20 1:50 PM
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.
2012 Mar 21 10:23 AM
Hi,
Please check the below link. It has been explained clearly.
Best Wishes,
Bharath.
2012 Apr 09 6:59 AM
@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