Quantcast
Channel: SCN: Message List - ABAP Connectivity
Viewing all articles
Browse latest Browse all 3125

Excel file in Mail attachment via BCS

$
0
0

Hi SCN,

 

 

When creating a Purchase Order (PO), an Output Type is triggered that will send some PO details to multiple mail adresses in an Excel file.

For this, I use the Business Communication Service (BCS) class from SAP (see SAP Note 1151258), so my code looks similar the the "BCS_EXAMPLE_7" report.

 

 

I convert my content string towards the UTF-16LE binary data format:

CALL METHOD cl_bcs_convert=>string_to_solix

         EXPORTING

           iv_string   = lv_content

           iv_codepage = '4103'   "UTF-16LE preferred by Microsoft Excel

           iv_add_bom  = lc_check  "Byte order mark

         IMPORTING

           et_solix    = lt_content

           ev_size     = lv_size.

 

Later in the program I add the attachment to the mail:

document->add_attachment(

         i_attachment_type    = 'xls'                        "#EC NOTEXT

         i_attachment_subject = lv_att_txt     

         i_attachment_size    = lv_size

         i_att_content_hex    = lt_content ).

 

The result is that the mail is correctly sent towards the recipients and the .xls attachment is correctly included:

mail.JPG

However, when opening the .xls document the following text has been generated:
error.JPG

By pressing "Yes" the Excel files opens correctly but the interface seems bugged (icons have disappeared on the menu bar).

However, all the data is displayed correctly.

result.JPG

The error that Excel is generating is due to the fact that the extension is ".xls" but the format is "Unicode Text" as displayed in Save As from Excel:

unicode text.JPG

 

Did any of you face the same problem or do you have a possible solution?

 

Thank you in advance for your response!

Best regards,

 

Niels De Greef


Viewing all articles
Browse latest Browse all 3125

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>