‎2008 Jun 02 1:11 PM
Hi Experts,
I am using the FM 'SO_NEW_DOCUMENT_ATT_SEND_API1' to send a CSV file format to a particular email id.
I gave the object type as "TXT" for body and
attachment object type as "EXT".
But when i opend the file with notepad format, i am not getting the line properly and its comiting one space inbetween for each character.
Please suggest on this,
Thanks,
Suresh
‎2008 Jun 02 2:59 PM
Hi,
- Write file fist to the file system of the server.
- Check if it is OK.
- Use similar code to this one:
&----
*& Form EMAIL
&----
FORM email USING emadr
xml_string_for_file.
DATA:
filebindat TYPE solix_tab,
f TYPE x,
i TYPE i,
wa LIKE solix,
size TYPE i,
fpath(128).
create file
***********
fpath = 'c:\tmp\l66.xml'.
OPEN DATASET fpath FOR OUTPUT IN TEXT MODE ENCODING UTF-8.
IF NOT sy-subrc IS INITIAL.
RAISE email_open_dataset.
EXIT.
ENDIF.
TRANSFER xml_string_for_file TO fpath.
IF NOT sy-subrc IS INITIAL.
RAISE email_transfer_dataset.
EXIT.
ENDIF.
CLOSE DATASET fpath.
IF NOT sy-subrc IS INITIAL.
RAISE email_close_dataset.
EXIT.
ENDIF.
create internal table with binary data
**************************************
OPEN DATASET fpath FOR INPUT IN BINARY MODE.
IF NOT sy-subrc IS INITIAL.
RAISE email_open_dataset2.
ENDIF.
DO.
IF i = 255.
APPEND wa TO filebindat.
CLEAR: wa, i.
ENDIF.
READ DATASET fpath INTO f.
IF NOT sy-subrc IS INITIAL.
EXIT.
ENDIF.
wa-line+i(1) = f.
size = size + 1.
i = i + 1.
ENDDO.
IF NOT wa IS INITIAL.
APPEND wa TO filebindat.
ENDIF.
CLOSE DATASET fpath.
send
****
DATA:
attach_size LIKE sood-objlen,
send_request TYPE REF TO cl_bcs,
text TYPE bcsy_text,
document TYPE REF TO cl_document_bcs,
recipient TYPE REF TO if_recipient_bcs,
bcs_exception TYPE REF TO cx_bcs,
sent_to_all TYPE os_boolean,
attsubj TYPE sood-objdes,
madr TYPE adr6-smtp_addr.
TRY.
send_request = cl_bcs=>create_persistent( ).
APPEND 'Here ist the attachment With xml-data for line 66.' TO text.
document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = text
i_subject = 'xml-data for line 66' ).
CONCATENATE 'l66_' sy-datum sy-uzeit '.xml' INTO attsubj.
attach_size = size.
document->add_attachment( i_attachment_type = 'BIN'
i_attachment_subject = attsubj
i_att_content_hex = filebindat
i_attachment_size = attach_size ).
send_request->set_document( document ).
madr = emadr.
recipient = cl_cam_address_bcs=>create_internet_address(
madr ).
send_request->add_recipient( i_recipient = recipient ).
sent_to_all = send_request->send( i_with_error_screen = 'X' ).
IF sent_to_all = 'X'.
MESSAGE s022(so).
ENDIF.
CATCH cx_bcs INTO bcs_exception.
MESSAGE e865(so) WITH bcs_exception->error_type.
ENDTRY.
COMMIT WORK.
ENDFORM. " EMAIL
regards
Walter Habich
‎2011 Nov 15 5:24 AM