Code: Alles auswählen.
form send_mail.
loop at itab3.
concatenate
itab3-vkorg
itab3-vbeln
itab3-kunnr
itab3-name1
itab3-text1
itab3-matnr
itab3-maktx
itab3-prctr
itab3-text2
itab3-c_wadat
itab3-c_olfmng
itab3-c_preis
itab3-waerk
itab3-c_netwr
itab3-c_hzdat
into itab10-v_transfer separated by ';'.
append itab10.
endloop.
* Daten
loop at itab10 assigning field-symbol(<s_itab>).
v_string = v_string &&
<s_itab>-v_transfer && cl_bcs_convert=>gc_crlf.
endloop. "itab
* Konvertieren nach binär
try.
cl_bcs_convert=>string_to_solix(
exporting
iv_string = v_string
iv_codepage = '4103'
iv_add_bom = abap_true
importing
et_solix = data(t_binary_content)
ev_size = data(v_size) ).
catch cx_bcs.
message e445(so).
return.
endtry.
* Inhalt Email-Body aus SO10-Text
call function 'READ_TEXT'
exporting
id = 'ST'
language = sy-langu
name = 'Z_EMAIL_BODY'
object = 'TEXT'
tables
lines = t_lines
exceptions
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
others = 8.
if sy-subrc ne 0.
v_html_txt = space.
else.
loop at t_lines assigning field-symbol(<s_lines>) where tdformat ne '/*'.
v_html_txt = v_html_txt && <s_lines>-tdline.
endloop.
endif.
* Email-Versand
try.
* Sende-Request anlegen
data(o_send_request) = cl_bcs=>create_persistent( ).
* Empfänger-Email-Adressen aus Selektionsmaske dem Sende-Request hinzufügen
* loop at itab10.
data(o_recipient) = cl_cam_address_bcs=>create_internet_address( mailname ). "Email-Adresse des Empfängers
o_send_request->add_recipient( i_recipient = o_recipient
i_express = abap_true ).
* endloop.
* Body erzeugen
data(t_body_txt) = cl_document_bcs=>string_to_soli( ip_string = v_html_txt ).
data(o_document) = cl_document_bcs=>create_document( i_type = 'HTM'
i_text = t_body_txt
i_subject = 'Täglicher Auftragsbestand' ). "Betreff
* txt-Datei anhängen
o_document->add_attachment( i_attachment_type = 'txt' "Datei-Endung
i_attachment_subject = 'SAP_BOOKEDORDERS'
i_attachment_size = v_size
i_att_content_hex = t_binary_content ).
* Dokument (Body und Anhang) an Sende-Request hängen
o_send_request->set_document( o_document ).
* senden und Status abfragen
if o_send_request->send( i_with_error_screen = abap_true ) = abap_true.
write: / 'Email gesendet.'.
else.
message 'Fehler beim Email-Versand' type 'E'.
endif.
commit work.
catch: cx_send_req_bcs, cx_document_bcs, cx_address_bcs.
message 'Fehler beim Email-Versand' type 'E'.
endtry.
endform.
Hi Alex,
Code: Alles auswählen.
DATA(zipper) = NEW cl_abap_zip( ).
DATA(binary_content) = cl_bcs_convert=>string_to_xstring( iv_string = v_string iv_codepage = '4103' ).
zipper->add( name = 'file.txt' content = binary_content ).
DATA(compressed_file) = zipper->save( ).