Code: Alles auswählen.
* Auselesen der Anzahl der Reports
DESCRIBE TABLE reports LINES anzahl.
if anzahl <> 0.
* Packing List(Anhang)
loop at reports into wa_reports.
kunnr = wa_reports-kunnr.
report = wa_reports-report.
* Erzeugen des PDFs um es anschließend zu verschicken
CALL FUNCTION 'ZNAK_S2_CREATEPDF'
EXPORTING
KUNNR = wa_reports-kunnr
report = wa_reports-report
TABLES
UNCOMPRESSED_PDF = pdf.
* Umwandeln des PDFs in das richtige Format
CALL FUNCTION 'ZNAK_S2_CONVERTPDF'
TABLES
PDF = pdf
OBJECT_BIN = object_bin.
describe table object_bin lines tab_lines.
read table object_bin index tab_lines.
object_pack-transf_bin = 'X'.
object_pack-head_start = 1.
object_pack-head_num = 0.
object_pack-body_start = z_start.
object_pack-body_num = tab_lines.
object_pack-doc_type = 'PDF'.
object_pack-obj_name = 'SPOOL'.
object_pack-obj_descr = 'Report'.
* object_pack-doc_size = tab_lines * 255.
data: laenge type int4.
laenge = ( tab_lines - 1 ) * 255 + strlen( object_bin ).
object_pack-doc_size = laenge.
append object_pack.
z_start = z_start + tab_lines.
endloop.
* Erstellen der Empfänger-Liste
* Externer Benutzer
receiver_list-receiver = email.
receiver_list-rec_type = 'U'.
append receiver_list.
* Interner Benutzer
receiver_list-receiver = USERNAME.
receiver_list-rec_type = 'B'.
append receiver_list.
fehler = 1.
* Sender der Email
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = document_data
PUT_IN_OUTBOX = 'X'
* COMMIT_WORK = 'X'
TABLES
PACKING_LIST = object_pack
CONTENTS_BIN = object_bin
CONTENTS_TXT = object_txt
RECEIVERS = receiver_list
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.
fehler = sy-subrc.
endif.