adesso orange🍊Stellenangebote:
Software Engineer Trainee · Senior
| (Senior) Cloud Software Engineer BTP
(Senior) Consultant Technologie · Consultant ABAP
Werkstudent Softwareentwicklung · Fiori / UI5 · Consulting · Application Management
E-Mail senden: Unterschied zwischen den Versionen
Aus SAP Wiki ツ
(Die Seite wurde neu angelegt: „Kategorie:Codeschnipsel === Deklaration === DATA: go_send_request TYPE REF TO cl_bcs, go_document TYPE REF TO cl_document_bcs,…“) |
|||
(3 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
Zeile 2: | Zeile 2: | ||
=== Deklaration === | === Deklaration === | ||
<syntaxhighlight lang="abap" line start="1"> | |||
DATA: go_send_request TYPE REF TO cl_bcs, | DATA: go_send_request TYPE REF TO cl_bcs, | ||
go_document TYPE REF TO cl_document_bcs, | go_document TYPE REF TO cl_document_bcs, | ||
Zeile 16: | Zeile 16: | ||
gv_data_tab_as_string TYPE string, | gv_data_tab_as_string TYPE string, | ||
gv_att_name TYPE sood-objdes. | gv_att_name TYPE sood-objdes. | ||
</syntaxhighlight> | |||
=== Codeschnipsel === | === Codeschnipsel === | ||
<syntaxhighlight lang="abap" line start="16"> | |||
go_send_request = cl_bcs=>create_persistent( ). | go_send_request = cl_bcs=>create_persistent( ). | ||
Zeile 71: | Zeile 72: | ||
COMMIT WORK. | COMMIT WORK. | ||
</syntaxhighlight> |
Aktuelle Version vom 12. August 2021, 08:01 Uhr
Deklaration
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_sender2 TYPE REF TO if_sender_bcs,
go_receiver TYPE REF TO if_recipient_bcs,
gt_mail_text_tab TYPE soli_tab,
gv_subject TYPE so_obj_des,
gt_distribution_list TYPE TABLE OF sodlienti1,
gv_recipient TYPE adr6-smtp_addr,
gv_size TYPE so_obj_len,
gt_binary_content TYPE solix_tab,
gv_data_tab_as_string TYPE string,
gv_att_name TYPE sood-objdes.
Codeschnipsel
go_send_request = cl_bcs=>create_persistent( ).
CONCATENATE 'Betreff' sy-datum INTO gv_subject SEPARATED BY space.
APPEND 'Mail Text in E-Mail' TO gt_mail_text_tab.
go_document = cl_document_bcs=>create_document( i_type = 'RAW'
i_text = gt_mail_text_tab
i_subject = gv_subject ).
***** Attachment: tab data as string to .xls
"new column: CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB
"new row: CL_ABAP_CHAR_UTILITIES=>CR_LF
cl_bcs_convert=>string_to_solix(
EXPORTING
iv_string = gv_data_tab_as_string
iv_codepage = '4103' "suitable for MS Excel, leave empty
iv_add_bom = 'X' "for other doc types
IMPORTING
et_solix = gt_binary_content
ev_size = gv_size ).
go_document->add_attachment(
EXPORTING
i_attachment_type = 'xls'
i_attachment_subject = gv_att_name
i_attachment_size = gv_size
i_att_content_hex = gt_binary_content ).
go_send_request->set_document( go_document ).
"Add sender variant 1
go_sender = cl_sapuser_bcs=>create( sy-uname ).
"Add sender variant 2
go_sender2 = cl_cam_address_bcs=>create_internet_address( i_address_string = iv_sender ).
go_send_request->set_sender( go_sender ). "go_send_request->set_sender( go_sender2 )
"Add receivers variant 1:
LOOP AT [[SO_DLI_READ_API1|gt_distribution_list]] INTO DATA(recpt).
gv_recipient = recpt-full_name.
go_receiver = cl_cam_address_bcs=>create_internet_address( gv_recipient ).
go_send_request->add_recipient( go_receiver ).
ENDLOOP.
"Add recievers variant 2:
go_receiver = cl_distributionlist_bcs=>getu_persistent( i_dliname = iv_distributionlist i_private = abap_false ).
go_send_request->add_recipient( go_receiver ).
go_send_request->send( ).
COMMIT WORK.