Skip to Content
0
Former Member
Mar 31, 2011 at 05:22 AM

Text splitting in Mail attachment

19 Views

Dear All,

I am facing aissue in sending a TXT attachment via mail. The text in the attachment is getting splitted after every 80 characters.

I've checked the data in the attachment in runtime, it is absolutely fine. Also, the attachment data in T-code SOST is also ok.

But the data in the attachment sent is aplititng after every 80 chars. Please find below the code I am using

LOOP AT gt_content INTO gs_content.

MOVE gs_content TO lt_objbin-line.

APPEND lt_objbin.

CLEAR lt_objbin.

ENDLOOP.

*Populating the attachment file

LOOP AT lt_objbin.

AT FIRST.

ENDAT.

CONDENSE lt_objbin-line.

CONCATENATE l_objbintxt lt_objbin-line INTO l_objbintxt.

CONDENSE l_objbintxt NO-GAPS.

ENDLOOP.

CLEAR it_attachment.

DESCRIBE TABLE it_attachment LINES l_rows_fa_start.

CLEAR l_start.

l_txtlen = strlen( l_objbintxt ).

WHILE l_txtlen > l_start.

MOVE l_objbintxt+l_start TO it_attachment-line.

CONDENSE it_attachment-line NO-GAPS.

APPEND it_attachment.

CLEAR it_attachment.

ADD 255 TO l_start.

ENDWHILE.

ld_format = 'TXT'.

**File Name

l_file = 'Netting Files'.

l_var = syst-sysid.

CONCATENATE l_file l_var INTO ld_attfilename

SEPARATED BY space.

  • Fill the document data.

gd_doc_data-doc_size = 1.

  • Populate the subject/generic message attributes

gd_doc_data-obj_langu = sy-langu.

gd_doc_data-obj_name = 'Netting Files'.

gd_doc_data-obj_descr = 'Netting Files' .

  • Fill the document data and get size of attachment

CLEAR gd_doc_data.

  • Populate the subject/generic message attributes

gd_doc_data-obj_langu = sy-langu.

DESCRIBE TABLE it_attachment LINES w_cnt.

READ TABLE it_attachment INDEX w_cnt.

gd_doc_data-doc_size = ( w_cnt - 1 ) * 255 + STRLEN( it_attachment ).

gd_doc_data-obj_name = 'Netting Files'.

gd_doc_data-obj_descr = 'Netting Files'.

  • Describe the body of the message

CLEAR it_packing_list.

REFRESH it_packing_list.

it_packing_list-transf_bin = space.

it_packing_list-head_start = 1.

it_packing_list-head_num = 0.

it_packing_list-body_start = 1.

DESCRIBE TABLE it_message LINES it_packing_list-body_num.

it_packing_list-doc_type = 'RAW'.

APPEND it_packing_list.

**Describe the attachment info

it_packing_list-transf_bin = 'X'.

it_packing_list-head_start = 1.

it_packing_list-head_num = 0.

it_packing_list-body_start = 1.

DESCRIBE TABLE it_attachment LINES it_packing_list-body_num.

it_packing_list-doc_type = ld_format.

it_packing_list-obj_name = ld_attfilename.

it_packing_list-obj_descr = ld_attfilename.

it_packing_list-doc_size = it_packing_list-body_num * 255.

APPEND it_packing_list.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = gd_doc_data

TABLES

packing_list = it_packing_list

contents_bin = it_attachment

contents_txt = it_message

receivers = lt_receiver

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.

Please suggest.

Thanks and Regards,

Neha Jindal