#TCODEDescription
1 | SOST | SAPconnect Send Requests |
2 | SU01 | User Maintenance |
3 | SCOT | SAPconnect ‑ Administration |
<style type="text/css"> SPAN { font-family: "돋움체"; font-size: 10pt; color: #000000; background: #FFFFFF; } .L0S31 { font-style: italic; color: #808080; background: #E6E6FA; } .L0S32 { color: #3399FF; } .L0S33 { color: #4DA619; } .L0S52 { color: #0000FF; } .L0S55 { color: #800080; } .L0S70 { color: #808080; } </style> FUNCTION ZBC_SEND_MAIL_IMMEDIATELY.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" VALUE(I_SUBJECT) TYPE SO_OBJ_DES "메일 제목
*" TABLES
*" T_HTML STRUCTURE SOLISTI1 OPTIONAL "메일 내용
*" T_RECV STRUCTURE SOMLRECI1 OPTIONAL "메일 수신자
*" EXCEPTIONS
*" MAIL_SENT_FAILED
*"----------------------------------------------------------------------
DATA : send_request TYPE REF TO cl_bcs.
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 : exception_info TYPE REF TO if_os_exception_info,
bcs_exception TYPE REF TO cx_bcs,
t_hex TYPE solix_tab,
t_text TYPE soli_tab,
w_text like LINE OF t_text,
html_string TYPE string,
xhtml_string TYPE xstring,
v_message(100),
v_mail TYPE sza5_d0700-smtp_addr.
CLEAR : html_string.
TRY.
* Create persistent send request
send_request = cl_bcs=>create_persistent( ).
loop at t_html.
move t_html-line to w_text-line.
append w_text to t_text.
ENDLOOP.
document = cl_document_bcs=>create_document(
i_type = 'HTM'
i_text = t_text
"i_hex = t_hex
i_subject = I_SUBJECT ).
* Add document to send request
CALL METHOD send_request->set_document( document ).
* Get sender object
sender = cl_sapuser_bcs=>create( sy-uname ).
* Add sender
CALL METHOD send_request->set_sender
EXPORTING
i_sender = sender.
LOOP AT T_RECV.
MOVE T_RECV-RECEIVER TO v_mail.
recipient = cl_cam_address_bcs=>create_internet_address( v_mail ).
* Add recipient with its respective attributes to send request
CALL METHOD send_request->add_recipient
EXPORTING
i_recipient = recipient.
ENDLOOP.
* Set that you don't need a Return Status E-mail
DATA: status_mail TYPE bcs_stml.
status_mail = 'N'.
CALL METHOD send_request->set_status_attributes
EXPORTING
i_requested_status = status_mail
i_status_mail = status_mail.
* set send immediately flag
send_request->set_send_immediately( 'X' ).
* Send document
CALL METHOD send_request->send( ).
COMMIT WORK.
CATCH cx_bcs INTO bcs_exception.
v_message = bcs_exception->get_text( ).
RAISE MAIL_SENT_FAILED.
ENDTRY.
ENDFUNCTION.
'IT > SAP' 카테고리의 다른 글
[SAP/BC/TroubleShoot] SAP RFC 계정 잠겼을 때 (0) | 2022.06.10 |
---|---|
[SAP/ABAP] Internal Table 선언 (0) | 2022.06.02 |
[SAP/BC] SAP Developer & Object Keys (0) | 2021.03.04 |
[SAP/ABAP/TroubleShoot]DBIF_DSQL2_SQL_ERROR (0) | 2021.01.07 |
[BC] SAP Tunning(2) (0) | 2020.05.19 |