‎2007 Apr 13 10:51 AM
Hi,
I am using the Function Module to send email with attachment. The program is running fine and i am able to send email with the attachment successfully. There are 10 lines in the internal table, but in the attachment i can see all of them in 5 or 6 lines. I want each record in a separate line. Please suggest me how to proceed this.
Secondly with the body of the message. How can we enter the text in new line?
Regards,
Phani.
‎2007 Apr 13 10:57 AM
‎2007 Apr 13 10:58 AM
‎2007 Apr 13 11:20 AM
Hi Prabhu,
As per your suggestion, i have checked the document size and corrected it. But the problem is still there.
Have a look at the code used to append the attachment table:
<b>
class cl_abap_char_utilities definition load.
constants:
con_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB,
con_cret type c value cl_abap_char_utilities=>CR_LF.
CONCATENATE 'EBELN' 'EBELP' 'AEDAT' 'MATNR'
INTO it_attach SEPARATED BY con_tab.
* CONCATENATE it_attach con_cret INTO it_attach.
APPEND it_attach.
LOOP AT it_ekpo INTO wa_charekpo.
CONCATENATE wa_charekpo-ebeln wa_charekpo-ebelp
wa_charekpo-aedat wa_charekpo-matnr
INTO it_attach SEPARATED BY con_tab.
* CONCATENATE it_attach con_cret INTO it_attach.
APPEND it_attach.
ENDLOOP.</b>
Code for Finding Document size and filling corresponding details:
<b>
CLEAR w_doc_data.
describe TABLE it_attach LINES w_cnt.
READ TABLE it_attach INDEX w_cnt.
w_doc_data-doc_size =
( w_cnt - 1 ) * 255 + 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'.
CLEAR t_attachment.
REFRESH t_attachment.
t_attachment[] = pit_attach[].</b>
Code of the FM:
<b>
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = w_doc_data
put_in_outbox = 'X'
sender_address = ld_sender_address
sender_address_type = ld_sender_address_type
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.</b>
Thanks in Advance,
Regards,
Phani.
‎2007 Apr 16 11:44 AM
describe TABLE it_attach LINES w_cnt.
READ TABLE it_attach INDEX w_cnt.
<b> w_doc_data-doc_size =
( w_cnt - 1 ) * 1055 + STRLEN( it_attach ).</b>
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'.
CLEAR t_attachment.
REFRESH t_attachment.
t_attachment[] = pit_attach[].
are u missing columns or rows ?
Regards
Prabhu
‎2007 Apr 13 11:08 AM
Hai,
Coming in 5 /6 lines is due to unequal lengths of internal tbale line length and the length of line in the out put file(generalluy 255 characters) you see.
So decrease the length of line filed in the internal table in you report.
Hope you could get it after this correction.
<b>Reward Points if it helps you.</b>
Regds,
Rama chary.Pammi