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: 

Upload XLSX and send Email with CL_DOCUMENT_BCS -> file is corrupt

Former Member
0 Kudos

Hi all,

i upload a XLSX file and send it with class CL_DOCUMENT_BCS to web Email adress. This works fine, but the file in the email is corrupt, if you open the XLSX file Excel display a popup that the file is corrupt and asks if i like to repair the file, this works and the file is then correct. But what is going wrong with the initialy correct xlsx file between workstation upload and send via email?

Here the short code:


CALL METHOD cl_gui_frontend_services=>gui_upload

   EXPORTING

     filename = p_file   " TYPE string DEFAULT 'C:\Temp\OP_LIST.xlsx'.

     filetype = 'BIN'

   CHANGING

     data_tab = t_data. " TYPE solix_tab


* set correct file extension

APPEND INITIAL LINE TO t_att_header ASSIGNING FIELD-SYMBOL(<lw_att_header>).

       <lw_att_header> = '&SO_FILENAME=OP_LIST.XLSX'.

       CALL METHOD:

         document->add_attachment

           EXPORTING

             i_attachment_type    = 'RAW' " BIN XLS XML -> allways same result

             i_attachment_subject = 'My attachment'

             i_att_content_hex    = t_data

             i_attachment_header  = t_att_header,

Thanks for help!

Wolfgang

1 ACCEPTED SOLUTION

Former Member

Hi,


I think you have to send the document size in I_ATTACHMENT_SIZE in the ADD_ATTACHMENT method.


So calculate the size of t_data table (check the exporting parameters FILELENGTH / HEADER in GUI_UPLOAD Method ) and pass it the method.


R

2 REPLIES 2

Former Member

Hi,


I think you have to send the document size in I_ATTACHMENT_SIZE in the ADD_ATTACHMENT method.


So calculate the size of t_data table (check the exporting parameters FILELENGTH / HEADER in GUI_UPLOAD Method ) and pass it the method.


R

0 Kudos

So easy, so long searching for a solution, the missing document size was the missing paramter! thanks Roy!