BCS SET EMAIL
FUNCTION zcrm_send_email.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(IV_SUBJECT) TYPE SO_OBJ_DES OPTIONAL
*" VALUE(IV_SENDER_EMAL) TYPE ADR6-SMTP_ADDR OPTIONAL
*" VALUE(IV_SENDER_NAME) TYPE ADR6-SMTP_ADDR OPTIONAL
*" VALUE(IV_COMMON_BODY1) TYPE FLAG DEFAULT ABAP_TRUE
*" VALUE(IV_COMMON_BODY2) TYPE FLAG DEFAULT ABAP_TRUE
*" VALUE(IV_EXCEL_AS_BODY) TYPE FLAG OPTIONAL
*" VALUE(IV_EXCEL) TYPE FLAG OPTIONAL
*" VALUE(IV_PDF) TYPE FLAG OPTIONAL
*" VALUE(IT_TABLE) TYPE ANY TABLE OPTIONAL
*" TABLES
*" IT_BODYS STRUCTURE SOLISTI1 OPTIONAL
*" IT_RECIPIENTS_EMAIL STRUCTURE BAPIADSMTP OPTIONAL
*" IT_CC_RECIPIENTS_EMAIL STRUCTURE BAPIADSMTP OPTIONAL
*"----------------------------------------------------------------------
FIELD-SYMBOLS:
<fs_comp> TYPE abap_compdescr,
<fs_value> TYPE any,
<fs_line> TYPE any,
<fs_col> TYPE any.
DATA:
gs_bapiadsmtp TYPE bapiadsmtp,
gr_cx_send_req_bcs TYPE REF TO cx_send_req_bcs,
gv_os_boolean TYPE os_boolean,
gr_send_request TYPE REF TO cl_bcs,
gr_document TYPE REF TO cl_document_bcs,
gr_recipient TYPE REF TO if_recipient_bcs,
gr_bcs_exception TYPE REF TO cx_bcs,
gr_sender TYPE REF TO if_sender_bcs. TRY.
* create persistent send request ------------------------
FREE gr_send_request.
gr_send_request = cl_bcs=>create_persistent( ).
* Start program frm_set_mail_document-Begin
REFRESH:gt_solisti1.
*IV_COMMON_BODY1-Begin
IF iv_common_body1 = abap_true.
gs_solisti1 = '<html><body>'.
APPEND gs_solisti1 TO gt_solisti1.
ENDIF.
*IV_COMMON_BODY1-End *IT_BODYS
IF it_bodys[] IS NOT INITIAL.
APPEND LINES OF it_bodys TO gt_solisti1.
ENDIF.
*IT_TABLE 如果非空的话获取共用抬头数据
REFRESH:gt_ddfields.
IF it_table IS NOT INITIAL.
LOOP AT it_table ASSIGNING <gs_line> .
IF gt_ddfields[] IS INITIAL.
gr_cl_abap_structdescr ?= cl_abap_typedescr=>describe_by_data( <gs_line> ).
*表头
IF gt_ddfields[] IS INITIAL.
CALL METHOD gr_cl_abap_structdescr->get_ddic_field_list
EXPORTING
p_langu = sy-langu
RECEIVING
p_field_list = gt_ddfields
EXCEPTIONS
not_found =
no_ddic_type =
OTHERS = .
IF sy-subrc <> .
* Implement suitable error handling here
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
*IV_EXCEL_AS_BODY
IF iv_excel_as_body = abap_true.
IF it_table IS NOT INITIAL.
gs_solisti1 = '<table border="1">'.
APPEND gs_solisti1 TO gt_solisti1.
gs_solisti1 = '<tr>'.
APPEND gs_solisti1 TO gt_solisti1.
* Excel抬头
CLEAR:gs_solisti1.
LOOP AT gt_ddfields INTO gs_ddfields.
CLEAR:gs_solisti1.
* IF gs_solisti1 IS INITIAL.
* CONCATENATE '<td>' gs_ddfields-fieldtext '</td>' INTO gs_solisti1.
* ELSE.
* CONCATENATE gs_solisti1 '<td>' gs_ddfields-fieldtext '</td>' INTO gs_solisti1.
* ENDIF.
CONCATENATE '<td>' gs_ddfields-fieldtext '</td>' INTO gs_solisti1.
APPEND gs_solisti1 TO gt_solisti1.
ENDLOOP.
* Excel 数据
LOOP AT it_table ASSIGNING <gs_line>.
*表内容
gs_solisti1 = '<tr>'.
APPEND gs_solisti1 TO gt_solisti1.
LOOP AT gr_cl_abap_structdescr->components ASSIGNING <fs_comp>.
CLEAR:gs_solisti1.
ASSIGN <fs_comp>-name TO <fs_col>.
ASSIGN COMPONENT <fs_col> OF STRUCTURE <gs_line> TO <gs_field>.
WRITE <gs_field> TO gv_field.
CONCATENATE '<td >' gv_field '</td> ' INTO gs_solisti1.
APPEND gs_solisti1 TO gt_solisti1.
ENDLOOP.
gs_solisti1 = '</tr>'.
APPEND gs_solisti1 TO gt_solisti1.
ENDLOOP.
gs_solisti1 = '</table>'.
APPEND gs_solisti1 TO gt_solisti1.
ENDIF.
ENDIF.
*IV_COMMON_BODY2-Begin
IF iv_common_body2 = abap_true.
gs_solisti1 = '<br>'.
APPEND gs_solisti1 TO gt_solisti1.
gs_solisti1 = '<br>'.
APPEND gs_solisti1 TO gt_solisti1.
gs_solisti1 = 'Hisense Service'.
APPEND gs_solisti1 TO gt_solisti1.
gs_solisti1 = '<br>'.
APPEND gs_solisti1 TO gt_solisti1.
gs_solisti1 = '0860 447 3673'.
APPEND gs_solisti1 TO gt_solisti1.
gs_solisti1 = '<br>'.
APPEND gs_solisti1 TO gt_solisti1.
gs_solisti1 = 'service@hisense.co.za'.
APPEND gs_solisti1 TO gt_solisti1.
ENDIF.
*IV_COMMON_BODY2-End
IF iv_common_body1 = abap_true.
gs_solisti1 = '<br>'.
APPEND gs_solisti1 TO gt_solisti1.
gs_solisti1 = '</body></html>'.
APPEND gs_solisti1 TO gt_solisti1.
ENDIF. gr_document = cl_document_bcs=>create_document(
i_type = 'HTM'
i_text = gt_solisti1
i_subject = iv_subject ). * Start program frm_set_mail_document-End * Define Attachment frm_set_mail_attachment-Begin
IF iv_excel = abap_true.
****EXCEL附加抬头
CLEAR:gv_string,gv_lines,gv_number.
DESCRIBE TABLE gt_ddfields LINES gv_lines.
LOOP AT gt_ddfields INTO gs_ddfields.
gv_number = gv_number + .
IF gv_lines = gv_number.
CONCATENATE gv_string gs_ddfields-fieldtext gc_crlf INTO gv_string.
ELSE.
IF gv_string IS INITIAL.
CONCATENATE gs_ddfields-fieldtext gc_tab INTO gv_string.
ELSE.
CONCATENATE gv_string gs_ddfields-fieldtext gc_tab INTO gv_string.
ENDIF.
ENDIF.
ENDLOOP.
****EXCEL附加内容
LOOP AT it_table ASSIGNING <gs_line>.
gr_cl_abap_structdescr ?= cl_abap_typedescr=>describe_by_data( <gs_line> ).
CLEAR:gv_number.
LOOP AT gr_cl_abap_structdescr->components ASSIGNING <fs_comp>.
gv_number = gv_number + .
ASSIGN <fs_comp>-name TO <fs_col>.
ASSIGN COMPONENT <fs_col> OF STRUCTURE <gs_line> TO <gs_field>.
WRITE <gs_field> TO gv_field.
IF gv_lines = gv_number.
CONCATENATE gv_string gv_field gc_crlf INTO gv_string.
ELSE.
CONCATENATE gv_string gv_field gc_tab INTO gv_string.
ENDIF.
ENDLOOP.
ENDLOOP.
* Convert string to xstring type
* 'APPLICATION/MSEXCEL;charset=utf-16le'
CLEAR:gv_xstring.
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = gv_string
mimetype = gc_mimetype
IMPORTING
buffer = gv_xstring
EXCEPTIONS
failed =
OTHERS = .
* Add the file header for utf-16le. .
IF sy-subrc = .
CONCATENATE cl_abap_char_utilities=>byte_order_mark_little
gv_xstring INTO gv_xstring IN BYTE MODE.
ENDIF.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = gv_xstring
TABLES
binary_tab = gt_solix. *Create attachment notification
gr_document->add_attachment(
i_attachment_type = 'XLS'""XXL XLS
i_attachment_subject = iv_subject
i_att_content_hex = gt_solix ).
ENDIF. *add document object to send request
TRY.
gr_send_request->set_document( gr_document ).
CATCH cx_send_req_bcs INTO gr_cx_send_req_bcs.
* MESSAGE i605(sbcoms) .
* pv_subrc = 4.
ENDTRY.
* Define Attachment frm_set_mail_attachment-End * Sender addess frm_set_sender-Begin
IF iv_sender_emal IS INITIAL.
iv_sender_emal = iv_sender_name = 'service@hisense.co.za'.
ENDIF.
CALL METHOD cl_cam_address_bcs=>create_internet_address
EXPORTING
i_address_string = iv_sender_emal "'europe@hisense.com'
i_address_name = iv_sender_name "'europe@hisense.com'
RECEIVING
result = gr_sender.
CALL METHOD gr_send_request->set_sender
EXPORTING
i_sender = gr_sender. * Sender addess frm_set_sender-End
* create receiver list frm_set_receiver_list-Begin
***收件人处理
LOOP AT it_recipients_email INTO gs_bapiadsmtp.
IF sy-uname = zcl_crm_attributes=>gc_chenguoguang.
gs_bapiadsmtp-e_mail = 'airwolf_chen@163.com'.
ENDIF.
FREE gr_recipient.
gr_recipient = cl_cam_address_bcs=>create_internet_address( gs_bapiadsmtp-e_mail ).
gr_send_request->add_recipient( gr_recipient ).
ENDLOOP.
***抄送人处理
LOOP AT it_cc_recipients_email INTO gs_bapiadsmtp.
IF sy-uname = zcl_crm_attributes=>gc_chenguoguang.
gs_bapiadsmtp-e_mail = '744793323@qq.com'.
ENDIF.
FREE gr_recipient.
gr_recipient = cl_cam_address_bcs=>create_internet_address( gs_bapiadsmtp-e_mail ).
gr_send_request->add_recipient( EXPORTING i_copy = 'X' i_recipient = gr_recipient ).
ENDLOOP.
* create receiver list frm_set_receiver_list-End
* send mail
gr_send_request->set_send_immediately( 'X' ).
gv_os_boolean = gr_send_request->send( i_with_error_screen = '' ).
COMMIT WORK AND WAIT.
CATCH cx_bcs INTO gr_bcs_exception.
* MESSAGE i865(so) WITH lo_bcs_exception->error_type.
ENDTRY. ENDFUNCTION.
BCS SET EMAIL的更多相关文章
- 如何在网页中提取Email地址
开博好久了,今天第一次发表技术文档,之前总是将一些好的事例保存在电脑,时间久了找起来也很麻烦,所以还是放在博客里进行归类比较方便,这样也能将自己在学习过程中的一些心得体会分享给大家,也能给需要的人一点 ...
- 系统中没有邮件客户端设置autoLink=email会挂掉的问题
TextView的autoLink属性为我们提供了很大的便利性,当文本中有网址,邮箱或电话的时候可以让我们方便地执行打电话发邮件等动作,不过也有一些问题,比如说设置autoLink包含email属性, ...
- Email系列(QQ邮箱 + 含附件的邮箱案例 + 项目实战)
平台之大势何人能挡? 带着你的Net飞奔吧! http://www.cnblogs.com/dunitian/p/4822808.html 邮箱系列:https://github.com/duniti ...
- 应用层之E-mail服务及javaMail邮件发送的知识总结
关于Email服务你需要知道的知识点: 概述: 今天来介绍一下应用层的电子邮件服务,我们每天几乎都在用,电子邮件(email)服务也是一种基于C/S模式的服务,它采用的是一种"存储-转发&q ...
- 2.C#WinForm基础Email分析器
功能:输入Email地址,输出用户名和域名 string[] String.split(params char[] separator)(+5重载)) 返回的字符串数组包含此实例的字符串(由指定Uni ...
- BCS datetime 时间区间问题
BCS 整合sql表时发现以下问题: datetime字段在列表中带了时区,比如插入12-6号的数据,在sql中显示的是12-5 date类型字段无法正确识别,插入成功但报错 LobSystem (外 ...
- SSIS 实例——将SQL获取的信息传递到Email中
最近在为公司财务开发一个邮件通知时遇到了一个技术问题.原来我设计SSIS的是每天将ERP系统支付数据导出到财务支付平台后 Email 通知财务,然后财务到支付平台上进行支付操作.由于那个时候开发时间很 ...
- java发送 email
public class EmailUtils implements IAction { private static Logger logger = Logger.getLogger(EmailUt ...
- 使用QQ邮箱发送email(Python)
实际开发过程中使用到邮箱的概率很高,那么如何借助python使用qq邮箱发送邮件呢? 代码很简单,短短几行代码就可以实现这个功能. 使用到的模块有smtplib和email这个两个模块,关于这两个模块 ...
随机推荐
- 以结算价交易TAS和以市价交易TAM
CME Group的合约规格中提到TAS和TAM交易,如:Gold Futures Contract Specs Gold 期货 合约规格 Trading at Settlement (TAS) is ...
- 使用CSS实现三栏自适应布局(两边宽度固定,中间自适应)
来源:http://blog.csdn.net/cinderella_hou/article/details/52156333 所谓三列自适应布局指的是两边定宽,中间block宽度自适应.这道题在今年 ...
- HDU 4318 Power transmission(最短路)
http://acm.hdu.edu.cn/showproblem.php?pid=4318 题意: 给出运输路线,每条路线运输时都会损失一定百分比的量,给定起点.终点和初始运输量,问最后到达终点时最 ...
- BOM - 浏览器API
1,javascript 组成部分: 1.ECMAscript(核心标准): 定义了基本的语法,比如:if for 数组 字符串 ... 2.BOM : 浏览器对象模型(Browser ...
- js实现网站首页分享滑块
<!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8&quo ...
- 小程序之根据参数更改title
是这样的,今天呢在写中英文切换功能,哇 从psd图里面去复制英文在去对应,真的是太难受了 okok 切回正题 当用户选择英文的时候 我的title也要是英文怎么办呢 wx.setNaviga ...
- Navicat for MySQL用ssh功能连接远程数据库
转载自:http://holy2010.blog.51cto.com/1086044/518431 实现用本地的ssh隧道起到加密功能 在windows平台上运行Navicat for MySQL(h ...
- Flexbox弹性布局,更优雅的布局
Flexbox,更优雅的布局 Flex 布局教程:语法篇 Flex 布局教程:实例篇 2009年,W3C提出了一种新的方案----Flex布局,可以简便.完整.响应式地实现各种页面布局.目前,它已经得 ...
- C++ Web 编程
C++ Web 编程 什么是 CGI? 公共网关接口(CGI),是一套标准,定义了信息是如何在 Web 服务器和客户端脚本之间进行交换的. CGI 规范目前是由 NCSA 维护的,NCSA 定义 CG ...
- highchart柱状堆叠图动态数据请求
$(function () { var options = { chart: { renderTo: 'indoor', type: 'column', }, title: { text: '室内问题 ...