Code: Alles auswählen.
* Create the document which is to be sent
doc_chng-obj_name = 'List'.
doc_chng-obj_descr = 'Betreff:...'.
*Text
APPEND cu_mail-text TO objtxt.
DESCRIBE TABLE objtxt LINES tab_lines.
READ TABLE objtxt INDEX tab_lines.
doc_chng-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
* Fill the fields of the packing_list for the main document:
CLEAR objpack-transf_bin.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'RAW'.
APPEND objpack.
* Create the attachment (the list itself)
DESCRIBE TABLE sendtab LINES tab_lines.
* Fill the fields of the packing_list for the attachment:
objpack-transf_bin = 'X'.
* we need no header
objpack-head_start = 1.
objpack-head_num = 0.
* but a body
objpack-body_start = 1.
objpack-body_num = tab_lines.
* of type G_DOC_TYPE
objpack-doc_type = g_doc_type.
objpack-obj_name = 'Attachment'.
CONCATENATE 'test_' save_sy-datum INTO dsnout.
CONDENSE dsnout NO-GAPS.
objpack-obj_descr = dsnout(50).
objpack-doc_size = tab_lines * 255.
APPEND objpack.
Code: Alles auswählen.
DATA: e_document_data LIKE sodocchgi1.
DATA: t_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE.
DATA: t_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE.
DATA: t_object_header LIKE solisti1 OCCURS 0 WITH HEADER LINE.
DATA: t_contents_txt LIKE solisti1 OCCURS 0 WITH HEADER LINE.
DATA: t_contents_bin LIKE solisti1 OCCURS 0 WITH HEADER LINE.
DATA: tab_lines LIKE sy-tabix.
DATA: test_itab LIKE TABLE OF vbak WITH HEADER LINE.
DATA: wa_vbak LIKE vbak.
SELECT * FROM vbak INTO wa_vbak
WHERE vbeln > '0000009053'
AND vbeln < '0000010000'.
APPEND wa_vbak TO test_itab.
ENDSELECT.
* Daten für Mail
e_document_data-obj_name = 'Test'.
e_document_data-obj_descr = 'Test'.
t_contents_txt = 'Hallo, usw'.
APPEND t_contents_txt.
DESCRIBE TABLE t_contents_txt LINES tab_lines.
READ TABLE t_contents_txt INDEX tab_lines.
e_document_data-doc_size = ( tab_lines - 1 ) * 255
+ STRLEN( t_contents_txt ).
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
t_packing_list-body_num = tab_lines.
t_packing_list-doc_type = 'RAW'.
APPEND t_packing_list.
* Daten für Anhang
LOOP AT test_itab.
CONCATENATE test_itab-vbeln
test_itab-erdat test_itab-erzet test_itab-ernam
test_itab-angdt test_itab-bnddt test_itab-audat
test_itab-vbtyp test_itab-trvog
INTO t_contents_bin SEPARATED BY ';'.
APPEND t_contents_bin.
ENDLOOP.
DESCRIBE TABLE t_contents_bin LINES tab_lines.
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
t_packing_list-body_num = tab_lines.
t_packing_list-doc_type = 'CSV'.
t_packing_list-obj_name = 'ANLAGE'.
t_packing_list-doc_size = tab_lines * 255.
t_packing_list-obj_descr = 'Protokoll'.
APPEND t_packing_list.
t_receivers-receiver = 'empfaenger@test.de'.
t_receivers-rec_type = 'U'.
APPEND t_receivers.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = e_document_data
* PUT_IN_OUTBOX = ' '
* IMPORTING
* SENT_TO_ALL =
* NEW_OBJECT_ID =
TABLES
packing_list = t_packing_list
object_header = t_object_header
contents_bin = t_contents_bin
contents_txt = t_contents_txt
* CONTENTS_HEX =
* OBJECT_PARA =
* OBJECT_PARB =
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.
Code: Alles auswählen.
CONSTANTS: gcx_crlf(2) TYPE x VALUE '0A0C'.
Code: Alles auswählen.
* Daten für Anhang
LOOP AT test_itab.
CONCATENATE test_itab-vbeln
test_itab-erdat test_itab-erzet test_itab-ernam
test_itab-angdt test_itab-bnddt test_itab-audat
test_itab-vbtyp test_itab-trvog
INTO t_contents_bin SEPARATED BY ';'.
******** Neu - Zeilenvorschub *****
CONCATENATE t_contents_bin gcx_crlf INTO t_contents_bin .
APPEND t_contents_bin.
ENDLOOP.