Skip to Content
author's profile photo Former Member
Former Member

Sending Email with file attachment from SAP

Hi,

I try to send file of type 'DAT' as attachment.

The problem is that I receive all the data in one line.

How can I fix it?

My code is:

CALL FUNCTION 'TABLE_COMPRESS'

  • IMPORTING

  • COMPRESSED_SIZE =

TABLES

in = i_app

out = lt_objbinc

EXCEPTIONS

compress_error = 1

OTHERS = 2

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CALL FUNCTION 'TABLE_DECOMPRESS'

TABLES

in = lt_objbinc

out = lt_objbin

EXCEPTIONS

compress_error = 1

table_not_compressed = 2

OTHERS = 3.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

receiver_list-receiver = e_mail.

receiver_list-rec_type = 'U'.

receiver_list-com_type = 'INT'.

APPEND receiver_list.

mailhead = 'Applicants'.

APPEND mailhead.

lt_objtxt = 'list of applcants.'.

APPEND lt_objtxt.

DESCRIBE TABLE lt_objtxt LINES l_tab_lines.

READ TABLE lt_objtxt INDEX l_tab_lines.

ls_docdata-doc_size = ( l_tab_lines - 1 ) * 255 + STRLEN( lt_objtxt ).

CLEAR packing_list-transf_bin.

packing_list-head_start = 1.

packing_list-head_num = 0.

packing_list-body_start = 1.

packing_list-body_num = l_tab_lines.

packing_list-doc_type = 'RAW'.

APPEND packing_list.

DESCRIBE TABLE lt_objbin LINES l_tab_lines.

READ TABLE lt_objbin INDEX l_tab_lines.

packing_list-doc_size =

( l_tab_lines - 1 ) * 255 + STRLEN( lt_objbin ).

packing_list-transf_bin = 'X'.

packing_list-head_start = 1.

packing_list-head_num = 0.

packing_list-body_start = 1.

packing_list-body_num = l_tab_lines.

packing_list-doc_type = 'DAT' . "'TXT'.

packing_list-obj_name = 'attachment'.

packing_list-obj_descr = 'description.txt'.

APPEND packing_list.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = ls_docdata

put_in_outbox = 'X'

commit_work = 'X'

TABLES

packing_list = packing_list

object_header = mailhead

contents_hex = lt_objbin

contents_txt = lt_objtxt

receivers = receiver_list

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 <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Dec 02, 2007 at 11:21 AM

    Hi,

    Are you getting lt_objtxt text in multiple lines or in a single, Check in debugging before calling FM 'SO_NEW_DOCUMENT_ATT_SEND_API1'.

    Regards,

    Satish

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.