Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

sedning mail with XL attachement form 4.6B system

hi guys,

i got this code from SDN for sending XL/txt file attachment . when i used this code in ECC system this works perfectly. but when i put this code 4.6 B version system the FM SO_NEW_DOCUMENT_ATT_SEND_API1 is giving exception document_not_sent. do i need to use different FM in 4.6B. cna anybody change this code such that it works in 4.6B

DATA:

docdata LIKE sodocchgi1,

objpack LIKE sopcklsti1 OCCURS 1 WITH HEADER LINE,

objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE,

objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE,

reclist LIKE somlreci1 OCCURS 1 WITH HEADER LINE,

tab_lines TYPE sy-tabix.

DATA:

BEGIN OF i_data OCCURS 0,

a(20),

b(20),

END OF i_data.

  • Body

docdata-obj_name = 'Mail_Excel_File'.

docdata-obj_descr = 'Excel file attachment'.

objtxt = 'Attached is the sample Excel file'.

APPEND objtxt.

DESCRIBE TABLE objtxt LINES tab_lines.

READ TABLE objtxt INDEX tab_lines.

docdata-doc_size = ( tab_lines - 1 ) * 255 + strlen( objtxt ).

CLEAR objpack-transf_bin.

objpack-head_start = 1.

objpack-head_num = 0.

objpack-body_start = 1.

objpack-body_num = tab_lines.

objpack-doc_type = 'RAW'.

APPEND objpack.

  • Attachment

i_data-a = 'Sample'.

i_data-b = 'File'.

CONCATENATE i_data-a i_data-b INTO objbin.

APPEND objbin.

DESCRIBE TABLE objbin LINES tab_lines.

objpack-doc_size = tab_lines * 255.

objpack-transf_bin = 'X'.

objpack-head_start = 1.

objpack-head_num = 1.

objpack-body_start = 1.

objpack-body_num = tab_lines.

objpack-doc_type = 'XLS'.

docdata-obj_name = 'Excel_File_Attachment'.

objpack-obj_descr = 'Excel File Attachment'.

APPEND objpack.

  • Create the list of recipients

reclist-receiver = 'anybodyatgmail.com'.

reclist-rec_type = 'U'.

reclist-express = 'X'.

APPEND reclist.

  • Send the e-mail

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = docdata

put_in_outbox = 'X'

commit_work = 'X'

TABLES

packing_list = objpack

contents_bin = objbin

contents_txt = objtxt

receivers = reclist

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.

if sy-subrc eq 0.

write: /' test is successful'.

else.

write: /' test is not successful'.

endif.

COMMIT WORK.

Edited by: sudhakar murthy on Apr 23, 2009 4:19 PM

Former Member
Not what you were looking for? View more on this topic or Ask a question