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

Excel Attachment unrecognized format

Former Member
0 Likes
696

Hi,

I am trying to sand an excel attachment by email using

"SO_NEW_DOCUMENT_ATT_SEND_API1" FM from SAP 6.0. The file has been

transferred fine, but is going as an unrecognized format. Please give me

some suggestions regarding this.

using:

t_packing_list-doc_type = 'XLS'.

CALL FUNCTION 'SO_DOCUMENT_SEND_API1'

EXPORTING

document_data = w_doc_data

put_in_outbox = 'X'

commit_work = 'X'

IMPORTING

sent_to_all = w_sent_all

TABLES

packing_list = t_packing_list

contents_bin = t_attachment

contents_txt = it_message

receivers = t_receivers

EXCEPTIONS

too_many_receivers = 1

document_not_sent = 2

document_type_not_exist = 3

operation_no_authorization = 4

parameter_error = 5

x_error = 6

enqueue_error = 7

OTHERS = 8.

Thanks,

Goutham.

6 REPLIES 6
Read only

Former Member
0 Likes
677

It appears that you are sending the document type in the internal table header rather than the table itself.

Try:

t_packing_list-doc_type = 'XLS'.
append t_packing_list.

Rob

Oh yes - and welcome to SCN.

Edited by: Rob Burbank on Apr 21, 2009 1:05 PM

Read only

0 Likes
677

Yes Rob. I am appending the doc type to t_packing_list table.

DATA: t_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE

  • Create attachment notification

t_packing_list-transf_bin = 'X'.

t_packing_list-head_start = 1.

t_packing_list-head_num = 1.

t_packing_list-body_start = 1.

describe table t_attachment lines t_packing_list-body_num.

t_packing_list-doc_type = 'XLS'.

t_packing_list-obj_descr = ld_attdescription.

t_packing_list-obj_name = ld_attfilename.

t_packing_list-doc_size = t_packing_list-body_num * 255.

append t_packing_list.

Thanks.

Read only

0 Likes
677

w_doc_data-obj_langu = sy-langu.

w_doc_data-sensitivty = 'F'.

w_doc_data-proc_type = 'T'.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = w_doc_data

Welcome to SCN!!

Read only

0 Likes
677

Still the same after changing. Please let me know if I am missing some code.

  • Fill the document data and get size of attachment

CLEAR w_doc_data.

READ TABLE it_attach INDEX w_cnt.

w_doc_data-doc_size =

( w_cnt - 1 ) * 250 + STRLEN( it_attach ).

w_doc_data-obj_langu = sy-langu.

w_doc_data-obj_name = 'SAPRPT'.

w_doc_data-obj_descr = ld_mtitle.

w_doc_data-sensitivty = 'F'.

w_doc_data-proc_type = 'T'.

CLEAR t_attachment.

REFRESH t_attachment.

t_attachment[] = it_attach[].

  • Describe the body of the message

CLEAR t_packing_list.

REFRESH t_packing_list.

t_packing_list-transf_bin = space.

t_packing_list-head_start = 1.

t_packing_list-head_num = 0.

t_packing_list-body_start = 1.

DESCRIBE TABLE it_message LINES t_packing_list-body_num.

t_packing_list-doc_type = 'RAW'.

APPEND t_packing_list.

  • Create attachment notification

t_packing_list-transf_bin = 'X'.

t_packing_list-head_start = 1.

t_packing_list-head_num = 1.

t_packing_list-body_start = 1.

DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.

t_packing_list-doc_type = 'XLS'.

t_packing_list-obj_descr = ld_attdescription.

t_packing_list-obj_name = ld_attfilename.

t_packing_list-doc_size = t_packing_list-body_num * 255.

APPEND t_packing_list.

t_receivers-receiver = i_email-p_email.

t_receivers-rec_type = 'U'.

t_receivers-express = 'X'.

  • t_receivers-com_type = 'INT'.

  • t_receivers-notif_del = 'X'.

  • t_receivers-notif_ndel = 'X'.

APPEND t_receivers.

CALL FUNCTION 'SO_DOCUMENT_SEND_API1'

Thanks.

Read only

0 Likes
677

try

DESCRIBE TABLE it_message LINES t_packing_list-body_num.

t_packing_list-doc_type = 'RAW'.

APPEND t_packing_list.

  • Create attachment notification

t_packing_list-transf_bin = 'X'.

t_packing_list-head_start = 1.

t_packing_list-head_num = 1.

t_packing_list-body_start = 1.

DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.

t_packing_list-doc_type = 'XLS'. ">>>>>>>>>>>> try changing to RAW

t_packing_list-obj_descr = ld_attdescription.

Read only

0 Likes
677

It is saving as text file if I change to 'RAW' format. I think the issue is the excel file attachment is sent as tab delimited file, because when I open the excel file and try to save it again on my had disk it is saving as Text (tab delimited) file. Wont the excel file automatically recognize tab delimited file?

I am using the below constants as separators.

constants:

con_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab,

con_cret TYPE c VALUE cl_abap_char_utilities=>cr_lf.

Thanks.