Code: Alles auswählen.
DATA: send_request TYPE REF TO cl_bcs.
DATA: text TYPE bcsy_text.
DATA: document TYPE REF TO cl_document_bcs.
DATA: sender TYPE REF TO cl_sapuser_bcs.
DATA: recipient TYPE REF TO if_recipient_bcs.
DATA: bcs_exception TYPE REF TO cx_bcs.
DATA: sent_to_all TYPE os_boolean,
lv_file TYPE c LENGTH 50,
lz_table type TABLE OF spfli.
SELECT * UP TO 1000 ROWS FROM spfli INTO TABLE lz_table.
TRY.
* -------- create persistent send request ------------------------
send_request = cl_bcs=>create_persistent( ).
* -------- create and set document -------------------------------
* create document from internal table with text
APPEND 'Hello world!' TO text.
document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = text
i_length = '12'
i_subject = 'test created by BCS_EXAMPLE_1' ).
lv_file = 'Testanhang'.
document->add_attachment(
i_attachment_type = 'RAW' "#EC NOTEXT
i_attachment_subject = lv_file "#EC NOTEXT
i_att_content_text = lz_table ).
CATCH cx_document_bcs.
MESSAGE 'Table not attached' TYPE 'I'.
* add document to send request
CALL METHOD send_request->set_document( document ).
* --------- set sender -------------------------------------------
* note: this is necessary only if you want to set the sender
* different from actual user (SY-UNAME). Otherwise sender is
* set automatically with actual user.
sender = cl_sapuser_bcs=>create( sy-uname ).
CALL METHOD send_request->set_sender
EXPORTING
i_sender = sender.
* --------- add recipient (e-mail address) -----------------------
* create recipient - please replace e-mail address !!!
recipient = cl_cam_address_bcs=>create_internet_address(
'blabla@bla.com').
* add recipient with its respective attributes to send request
CALL METHOD send_request->add_recipient
EXPORTING
i_recipient = recipient
i_express = 'X'.
* ---------- send document ---------------------------------------
CALL METHOD send_request->send(
EXPORTING
i_with_error_screen = 'X'
RECEIVING
result = sent_to_all ).
IF sent_to_all = 'X'.
WRITE text-003.
ENDIF.
COMMIT WORK.
Code: Alles auswählen.
concatenate lv_string
ls_t100-arbgb gc_tab
ls_t100-msgnr gc_tab
ls_t100-sprsl gc_tab
ls_t100-text gc_crlf
into lv_string.
Code: Alles auswählen.
SELECT * UP TO 1000 ROWS FROM (db_tab) INTO TABLE lz_table.
LOOP AT lz_table INTO <ls_tablecontent>.
Loop at fieldcatalog into ls_fieldcatalog.
concatenate lv_string gc_tab <ls_tablecontent>-(fieldcatalog-fieldname) ?
endloop.
ENDLOOP.