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: 

problem with email attachment

Former Member
0 Kudos

Hi All!

I am using FM SO_NEW_DOCUMENT_ATT_SEND_API1 to send a excel file as an attachment to a email address and I am facing the following problem.

After I receive the email along with excel attachment if i try to open the excel attachment I am getting an warning saying

" THIS FILE IS NOT IN A RECOGNIZABLE FORMAT"

but if i say okay I am getting the required ecxel data which i sent through email.

Why i am gettinmg this warning .Please advise

Regards

Praneeth

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Sounds like you are not building the e-mail and the attachment correctly prior to calling the FM.

Please provide your code for review.

3 REPLIES 3

Former Member
0 Kudos

Sounds like you are not building the e-mail and the attachment correctly prior to calling the FM.

Please provide your code for review.

0 Kudos

Hi John

I am attaching my code below..

w_doc_chng-obj_descr = text-100.

w_doc_chng-obj_name = text-101.

*BODY OF THE MAIL

w_objtxt = text-102.

APPEND w_objtxt TO i_objtxt.

w_objtxt = text-105.

APPEND w_objtxt TO i_objtxt.

w_objtxt = text-103.

APPEND w_objtxt TO i_objtxt.

w_objtxt = text-105.

APPEND w_objtxt TO i_objtxt.

w_objtxt = text-104.

APPEND w_objtxt TO i_objtxt.

w_objtxt = text-105.

APPEND w_objtxt TO i_objtxt.

w_objtxt = text-106.

APPEND w_objtxt TO i_objtxt.

w_objtxt = text-107.

APPEND w_objtxt TO i_objtxt.

  • CLEAR w_objtxt.

  • To determine document size.

DESCRIBE TABLE i_objtxt LINES tab_lines.

READ TABLE i_objtxt INTO w_objtxt INDEX tab_lines.

w_doc_chng-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( w_objtxt ).

APPEND w_doc_chng TO i_doc_chng.

CLEAR w_doc_chng.

READ TABLE i_doc_chng INTO w_doc_chng INDEX 1.

  • Creating the entry for document

CLEAR w_objpack-transf_bin.

w_objpack-head_start = 1.

w_objpack-head_num = 0.

w_objpack-body_start = 1.

w_objpack-body_num = tab_lines.

w_objpack-doc_type = 'RAW'.

APPEND w_objpack TO i_objpack.

  • Creating the document attachment

LOOP AT i_inv_rep INTO w_inv_rep.

w_itobjbin-version_num = w_inv_rep-version_num.

w_itobjbin-date_of_run = w_inv_rep-date_of_run.

w_itobjbin-time_of_run = w_inv_rep-time_of_run.

w_itobjbin-company_code = w_inv_rep-company_code.

w_itobjbin-plant = w_inv_rep-plant.

w_itobjbin-bdc_item_no = w_inv_rep-bdc_item_no.

w_itobjbin-dcs_stock = w_inv_rep-dcs_stock.

APPEND w_itobjbin TO i_itobjbin.

ENDLOOP.

PERFORM build_xls_data_table .

DESCRIBE TABLE i_objbin LINES tab_lines.

w_objhead = 'Control Report.DAT'.

APPEND w_objhead TO i_objhead.

  • Creating the entry for the compressed attachment

w_objpack-transf_bin = 'X'.

w_objpack-head_start = 1.

w_objpack-head_num = 1.

w_objpack-body_start = 1.

w_objpack-body_num = tab_lines.

w_objpack-doc_type = 'xls'.

w_objpack-obj_name = 'ATTACHMENT'.

w_objpack-obj_descr = 'xls'.

w_objpack-doc_size = tab_lines * 255.

APPEND w_objpack TO i_objpack.

  • Entering names

w_reclist-receiver = 'kumapra@gmail.com'.

w_reclist-rec_type = 'U'.

APPEND w_reclist TO i_reclist.

Clear w_reclist.

  • Sending the document

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = w_doc_chng

put_in_outbox = 'X'

commit_work = 'X'

TABLES

packing_list = i_objpack

object_header = i_objhead

contents_bin = i_objbin

contents_txt = i_objtxt

receivers = i_reclist

EXCEPTIONS

too_many_receivers = 1

document_not_sent = 2

operation_no_authorization = 4

OTHERS = 99.

FORM build_xls_data_table .

CLEAR : i_objbin, i_objbin[].

CONCATENATE 'Version No.' 'Date of Program Run' 'Time of Program Run' 'Company Code' 'Plant'

'BDC Item' 'DCS Stock' INTO w_objbin SEPARATED BY

cl_abap_char_utilities=>horizontal_tab.

APPEND w_objbin TO i_objbin.

LOOP AT i_itobjbin INTO w_itobjbin .

CONCATENATE w_itobjbin-version_num w_itobjbin-date_of_run w_itobjbin-time_of_run w_itobjbin-company_code

w_itobjbin-plant w_itobjbin-bdc_item_no w_itobjbin-dcs_stock

INTO w_objbin SEPARATED BY cl_abap_char_utilities=>horizontal_tab.

CONCATENATE cl_abap_char_utilities=>cr_lf w_objbin INTO w_objbin.

APPEND w_objbin TO i_objbin.

ENDLOOP.

ENDFORM.

Please advise..

Regards

Praneeth

Former Member
0 Kudos

Hi Praneeth,

look at my coding in the following thread. I think this might help you.

Regards,

Georg-Stefan