Hi,
ich hänge mal ein Stückchen Coding dran. So sieht man welche Fuba´s und Methoden ich verwende.
Die ALV-Ausgabe sieht ganz gut aus. So hätte ich das auch bei meiner Excel-Ausgabe. Nur klappt das leider nicht

Wie bekomme ich meine Excel-Datei, die ich per Mail verschicke so, wie in der ALV-Ausgabe?
*&---------------------------------------------------------------------*
*& Form ergebnis_mailen
*&---------------------------------------------------------------------*
form ergebnis_mailen tables ut_cdred_output
using value(pv).
*Mail
data: lt_message type standard table of solisti1, " initial size 0 with header line.
lt_attachment type standard table of solisti1 initial size 0 with header line,
ls_mes type solisti1.
data: ls_packing type sopcklsti1,
lt_packing type standard table of sopcklsti1.
* Absender
data: lv_sender_address type soextreci1-receiver,
lv_sender_address_type type soextreci1-adr_typ.
* Empfänger
data: ls_receivers type somlreci1,
lt_receivers type standard table of somlreci1.
* Dokument
data: ls_doc_data type sodocchgi1.
data: lv_sent_all(1) type c.
* Nachricht füllen
ls_mes = 'Auswertung der Änderungen der Userdaten und deren Berechtigungen'.
append ls_mes to lt_message.
ls_mes = ' '.
append ls_mes to lt_message.
ls_mes = ' '.
append ls_mes to lt_message.
* Anhang aufbereiten
perform anhang_aufbereiten tables ut_cdred_output
using pv
changing lt_attachment[].
* Dokument Data
ls_doc_data-doc_size = 1.
ls_doc_data-obj_langu = sy-langu.
ls_doc_data-obj_name = 'Auswertung.xls'. "'SAPRPT'.
ls_doc_data-obj_descr = 'Auswertung der Änderungen der Userdaten und deren Berechtigungen'.
ls_doc_data-sensitivty = 'F'.
*--1 Describe the body of the message
clear: ls_packing, lt_packing.
ls_packing-transf_bin = space.
ls_packing-head_start = 1.
ls_packing-head_num = 0.
ls_packing-body_start = 1.
describe table lt_message lines ls_packing-body_num.
ls_packing-doc_type = 'RAW'.
append ls_packing to lt_packing.
*--2 Create attachment notification
ls_packing-transf_bin = 'X'.
ls_packing-head_start = 1.
ls_packing-head_num = 1.
ls_packing-body_start = 1.
describe table lt_attachment lines ls_packing-body_num.
ls_packing-doc_type = 'XLS'. "'RAW'.
ls_packing-obj_descr = 'Auswertung.xls'.
ls_packing-obj_name = 'Testdescription'.
ls_packing-doc_size = ls_packing-body_num * 255.
append ls_packing to lt_packing.
* Absender
lv_sender_address = sy-uname.
* eMail Empfänger
loop at so_mail.
clear lt_receivers.
ls_receivers-receiver = so_mail-low.
ls_receivers-rec_type = 'U'. " U = Internetadresse
ls_receivers-com_type = 'INT'.
ls_receivers-notif_del = 'X'.
ls_receivers-notif_ndel = 'X'.
append ls_receivers to lt_receivers.
endloop.
call function 'SO_DOCUMENT_SEND_API1'
exporting
document_data = ls_doc_data
put_in_outbox = 'X'
sender_address = lv_sender_address
sender_address_type = lv_sender_address_type
commit_work = 'X'
importing
sent_to_all = lv_sent_all
tables
packing_list = lt_packing
contents_bin = lt_attachment
contents_txt = lt_message
receivers = lt_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.
if sy-subrc <> 0.
message id sy-msgid type 'S' number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
* Populate zreceiver return code
loop at lt_receivers into ls_receivers.
if ls_receivers-retrn_code ne 0.
write: / 'Fehler beim Versenden der Nachricht.'.
endif.
endloop.
wait up to 4 seconds.
* Mail verschicken
submit rsconn01 with mode = 'INT' and return. " with output = 'X'
endform. " ergebnis_mailen
*&---------------------------------------------------------------------*
*& Form anhang_aufbereiten
*&---------------------------------------------------------------------*
form anhang_aufbereiten tables pt_cdred_output
using value(pv)
changing ct_attachment type gyt_attachment.
data: lv_string(255),
lv_attachment(255),
lv_field(22).
data: lt_usrcdt type table of usrcdt with header line,
lt_usrcd type table of usrcd with header line.
* Daten in passende interne Tabelle
if pv eq 'X'.
lt_usrcdt[] = pt_cdred_output[].
loop at lt_usrcdt. " into lv_string.
concatenate
lt_usrcdt-bname
* ggf weitere Felder für das Excel einfügen
*lt_usrcd-modda
*lt_usrcd-modti
*lt_usrcd-counter
lt_usrcd-modbe
*lt_usrcd-action
*lt_usrcd-old_val
*lt_usrcd-old_text
*lt_usrcd-new_val
*lt_usrcd-new_text
*lt_usrcd-name_first
*lt_usrcd-name_last
*pt_cdred_output-tcode
*pt_cdred_output-attrbt
*pt_cdred_output-subsystem
*pt_cdred_output-agr_fdate
*pt_cdred_output-agr_tdate
into lv_string separated by cl_abap_char_utilities=>horizontal_tab.
while lv_string <> space.
call function 'TEXT_SPLIT'
exporting
length = 255
text = lv_string
importing
line = lv_attachment
rest = lv_string.
if lv_string = space.
concatenate lv_attachment cl_abap_char_utilities=>cr_lf into lv_attachment.
endif.
append lv_attachment to ct_attachment.
clear lv_attachment.
endwhile.
endloop.
* Ausgabe nicht technisch.
else.
lt_usrcd[] = pt_cdred_output[].
loop at lt_usrcd. "into lv_string.
concatenate
lt_usrcd-bname
lt_usrcd-modda
lt_usrcd-modti
* ggf weitere Felder für das Excel einfügen
lt_usrcd-modbe
lt_usrcd-action
lt_usrcd-old_val
lt_usrcd-old_text
lt_usrcd-new_val
lt_usrcd-new_text
lt_usrcd-name_first
lt_usrcd-name_last
into lv_string separated by cl_abap_char_utilities=>horizontal_tab.
while lv_string <> space.
call function 'TEXT_SPLIT'
exporting
length = 255
text = lv_string
importing
line = lv_attachment
rest = lv_string.
if lv_string = space.
concatenate lv_attachment cl_abap_char_utilities=>cr_lf into lv_attachment.
endif.
append lv_attachment to ct_attachment.
clear lv_attachment.
endwhile.
endloop.
endif.
endform. " anhang_aufbereiten
Du hast keine ausreichende Berechtigung, um die Dateianhänge dieses Beitrags anzusehen.