Hallo Anchi,
generell solltest du dich entscheiden, ob du mit dem Fuba SO_NEW_DOCUMENT_ATT_SEND_API1 arbeitest oder mit dem BCS.
Letzteres ist einfacher, weil du u.a. keine Packliste aufbauen musst.
Was ist zu tun (hier ein paar Codestrecken, teilweise musst du sicher noch ein paar Variablen defineiren, aber die genannten Methoden reichen, um eine Mail zu verschicken):
Data:
go_send_request TYPE REF TO cl_bcs,
go_document TYPE REF TO cl_document_bcs,
go_sender TYPE REF TO cl_sapuser_bcs,
go_recipient TYPE REF TO if_recipient_bcs.
* Sendrequest erzeugen
go_send_request = cl_bcs=>create_persistent( ).
* Dokument (Mailtext) erzeugen
CALL METHOD cl_document_bcs=>create_document
EXPORTING
i_type = 'RAW'
i_subject = ps_text_header-tdtitle
i_text = pt_mail_text
RECEIVING
result = go_document.
* Die Mail an den Sendrequest hängen
CALL METHOD go_send_request->set_document( go_document ).
* Sender
go_sender = cl_sapuser_bcs=>create( p_sender ).
CALL METHOD go_send_request->set_sender
EXPORTING
i_sender = go_sender.
* Empfänger
LOOP AT pr_receiver INTO ls_receiver.
CHECK ls_receiver-low IS NOT INITIAL.
lo_recipient = cl_cam_address_bcs=>create_internet_address(
ls_receiver-low ).
CALL METHOD go_send_request->add_recipient
EXPORTING
i_recipient = go_recipient
i_express = 'X'.
ENDLOOP.
* Copyempfänger
LOOP AT pr_copyreceiver INTO ls_receiver.
CHECK ls_receiver-low IS NOT INITIAL.
lo_recipient = cl_cam_address_bcs=>create_internet_address(
ls_receiver-low ).
CALL METHOD go_send_request->add_recipient
EXPORTING
i_recipient = go_recipient
i_express = 'X'
i_copy = 'X'.
ENDLOOP.
* Attachement anhängen (pdf)
TRY.
CALL METHOD go_document->add_attachment
EXPORTING
i_attachment_type = 'pdf' "Dateiextension
i_attachment_subject = lv_att_subject "Dateiname
i_att_content_text = pt_pdf.
CATCH cx_bcs INTO lo_bcs_exception.
MESSAGE e119(ku) WITH 'MAIL_ATTACHMENT'
lo_bcs_exception->error_type.
ENDTRY.
* Attachement anhängen (xls)
TRY.
CALL METHOD go_document->add_attachment
EXPORTING
i_attachment_type = 'xls' "Dateiextension
i_attachment_subject = lv_att_subject "Dateiname
i_att_content_text = pt_xls.
CATCH cx_bcs INTO lo_bcs_exception.
MESSAGE e119(ku) WITH 'MAIL_ATTACHMENT'
lo_bcs_exception->error_type.
ENDTRY.
* Attachement anhängen (doc)
TRY.
CALL METHOD go_document->add_attachment
EXPORTING
i_attachment_type = 'doc' "Dateiextension
i_attachment_subject = lv_att_subject "Dateiname
i_att_content_text = pt_doc.
CATCH cx_bcs INTO lo_bcs_exception.
MESSAGE e119(ku) WITH 'MAIL_ATTACHMENT'
lo_bcs_exception->error_type.
ENDTRY.
TRY.
* senden
CALL METHOD go_send_request->send(
EXPORTING
i_with_error_screen = 'X'
RECEIVING
result = gv_sent_to_all ).
IF lv_sent_to_all = 'X'.
* WRITE text-003.
ENDIF.
COMMIT WORK.
*----------------------------------------------------------------------*
* Ausnahmebehandlung
*----------------------------------------------------------------------*
CATCH cx_bcs INTO lo_bcs_exception.
MESSAGE e119(ku) WITH 'SEND_SPOOL' lo_bcs_exception->error_type.
ENDTRY.
hier noch ein paar Anmerkungen
- P_SENDER ist ein SAP-Username, wenn leer dann sy-uname
- Empfänger sind E-Mailadressen in der Form
OTTO@sowieso.de
Hoffe das hilft erst mal weiter
ST22