REPORT ZMMR0068_YYN.

CONSTANTS:
gc_tab TYPE c VALUE cl_bcs_convert=>gc_tab, "CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB
gc_crlf TYPE c VALUE cl_bcs_convert=>gc_crlf. "CL_ABAP_CHAR_UTILITIES=>CR_LF PARAMETERS: mailto TYPE ad_smtpadr . " 收件人 DATA send_request TYPE REF TO cl_bcs.
DATA document TYPE REF TO cl_document_bcs.
DATA recipient TYPE REF TO if_recipient_bcs.
DATA bcs_exception TYPE REF TO cx_bcs. DATA main_text TYPE bcsy_text.
DATA binary_content TYPE solix_tab.
DATA size TYPE so_obj_len.
DATA sent_to_all TYPE os_boolean. START-OF-SELECTION. PERFORM create_content.
PERFORM send. *&---------------------------------------------------------------------*
*& Form create_content
*&---------------------------------------------------------------------*
* Create Example Content
* 1) Write example text into a string
* 2) convert this string to solix_tab
*----------------------------------------------------------------------*
FORM create_content. DATA lv_string TYPE string.
DATA ls_t100 TYPE t100. * --------------------------------------------------------------
* as example content we use some system messages out of t100
* get them for all installed languages from db
* and write one line for each language into the spread sheet
* columns are separated by TAB and each line ends with CRLF CONCATENATE 'This Is Just Example Text!'
gc_crlf gc_crlf
INTO lv_string. DO TIMES.
CONCATENATE lv_string
'' gc_tab
'' gc_tab
'' gc_tab
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' gc_tab
'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' gc_tab
'ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc' gc_tab
'ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd' gc_tab
'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee' gc_tab
'fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' gc_tab
'ggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg' gc_tab
'hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh' gc_tab
'iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii' gc_tab
'jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj' gc_tab
'kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk' gc_crlf
INTO lv_string.
ENDDO.
* --------------------------------------------------------------
* convert the text string into UTF-16LE binary data including
* byte-order-mark. Mircosoft Excel prefers these settings
* all this is done by new class cl_bcs_convert (see note 1151257) TRY.
cl_bcs_convert=>string_to_solix(
EXPORTING
iv_string = lv_string
iv_codepage = '' "suitable for MS Excel, leave empty
iv_add_bom = 'X' "for other doc types
IMPORTING
et_solix = binary_content
ev_size = size ).
CATCH cx_bcs.
MESSAGE e445(so).
ENDTRY. ENDFORM. "create_content *---------------------------------------------------------------
* NOTES:
*---------------------------------------------------------------
* UTF-16LE including the BOM (Byte order mark)
* is preferred by Microsoft Excel. If you want to create
* other binary content you may choose another codepage (e.g.
* '4110' (UTF-8) which is standard for e-mails).
* Find SAP codepage names in the drop down list
* for the codepage setting of node SMTP in transaction SCOT.
* Or: leave iv_codepage and iv_add_bom empty. Then the target
* codepage is set according to SAPconnect settings
*
* Important:
* SAP neither guarantees that the attachment created
* by this report can be opened by all Excel Versions nor
* that it can be opened by any 3rd party software at all *&---------------------------------------------------------------------*
*& Form send
*&---------------------------------------------------------------------*
FORM send. TRY. * -------- create persistent send request ------------------------
send_request = cl_bcs=>create_persistent( ). * -------- create and set document with attachment ---------------
* create document object from internal table with text
APPEND 'Hello world!' TO main_text. " 邮件内容
document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = main_text
i_subject = 'Test Created By BCS_EXAMPLE_7' ). " 邮件主题名 * add the spread sheet as attachment to document object
document->add_attachment(
i_attachment_type = 'xls' " 附件格式
i_attachment_subject = 'ExampleSpreadSheet' " attachment name
i_attachment_size = size "附件大小
i_att_content_hex = binary_content ). "附件内容 * add document object to send request
send_request->set_document( document ). * --------- add recipient (e-mail address) -----------------------
* create recipient object
recipient = cl_cam_address_bcs=>create_internet_address( mailto ). * add recipient object to send request
send_request->add_recipient( recipient ). * ---------- send document ---------------------------------------
sent_to_all = send_request->send( i_with_error_screen = 'X' ). COMMIT WORK.
WAIT UP TO SECONDS.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
IF sent_to_all IS INITIAL.
MESSAGE i500(sbcoms) WITH mailto.
ELSE.
MESSAGE s022(so).
ENDIF.
* ------------ exception handling ----------------------------------
* replace this rudimentary exception handling with your own one !!!
CATCH cx_bcs INTO bcs_exception.
MESSAGE i865(so) WITH bcs_exception->error_type.
ENDTRY. ENDFORM. "send

SAP 发送邮件 面向对象的更多相关文章

  1. SAP系统邮件功能配置

    相信SAP顾问或多或少都会接到用户要求SAP系统能够定时发送邮件的功能,定时将用户需要的信息已邮件的方式发送给固定的人员. 下面就来讲一下SAP发送邮件应该如何配置: 1.RZ10做配置: is/SM ...

  2. 反应堆模式最牛的那篇论文--由solidmango执笔翻译

    The Reactor:An Object-Oriented Wrapper for Event-Driven Port Monitoring and Service Demultiplexing 反 ...

  3. [SAP ABAP开发技术总结]将文件存储到数据库表中,并可发送邮件

    声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...

  4. [SAP ABAP开发技术总结]面向对象OO

    声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...

  5. 第8课:异常处理、面向对象编程、发送邮件、url编码

    1. 异常处理 import traceback import pymysql import requests def calc(a, b): res = a / b return res def m ...

  6. 一百零六、SAP的OOP面向对象编程,OO-ALV的简介

    面向对象编程,如图 基本概念: 1.对象(Object)是一个现实实体的抽象.一个对象可被认为是一个把数据(属性)和程序(方法)封装在一起的实体,这个程序产生该对象的动作或对它接受到的外界信号的反应. ...

  7. 对面向对象的理解—— SAP电面(1)

    对于C++面向对象的理解 面向对象是在结构化设计方法出现很多问题的情况下应运而生的.结构化设计方法求解问题的基本策略是从功能的角度审视问题域.它将应用程序看成实现某些特定任务的功能模块,其中子过程是实 ...

  8. SAP中发送邮件

    WITH HEADER LINE, docdata LIKE sodocchgi1, objtxt WITH HEADER LINE, objpack WITH HEADER LINE, reclis ...

  9. python 面向对象初级篇

    Python 面向对象(初级篇) 概述 面向过程:根据业务逻辑从上到下写垒代码 函数式:将某功能代码封装到函数中,日后便无需重复编写,仅调用函数即可 面向对象:对函数进行分类和封装,让开发" ...

随机推荐

  1. 当今游戏大作share的特性大盘点

    极品游戏制作时的考虑要素大盘点 不知不觉入坑Steam已近4年,虽然说Steam的毒性让很多人走向一条不归路,但是想我这样即使"中毒"还是很快乐很感恩的.那么本期文章就谈谈我对其中 ...

  2. 【Alpha阶段】第三次scrum meeting

    每日任务: ·1.本次会议为第三次Meeting会议: ·2.本次会议于今日上午08:30第五社区五号楼下召开,会议时长15min. 二.每个人的工作: 三.工作中遇到的困难: 由于对编程语言的学习不 ...

  3. 201521123099 《Java程序设计》第八周学习总结

    1. 本周学习总结 2. 书面作业 本次作业题集集合 List中指定元素的删除(题目4-1) 1.1 实验总结 老师上课解释的还有私下问同学大概能懂.主要理解到一点在删除List中元素时要考虑元素删除 ...

  4. Java:双括号初始化 /匿名内部类初始化法

    偶然见到一种初始化方式,感到十分新奇: //新建一个列表并赋初值A.B.C ArrayList<String> list = new ArrayList<String>() { ...

  5. mysql查询文章的评论数量

    作为小白的我,这个问题弄了半天才解决,特此记录下. 两张表:文章表和评论表 文章表(article):id 评论表(comment):id,c_aid 要求:查询出所有文章及评论数量然后降序显示(没有 ...

  6. Activiti第三篇【连接、排他网关、指定任务处理人、组任务】

    连线 上面我们已将学过了流程变量了,可以在[任务服务.运行时服务.流程开始.完成某个任务时设置流程变量],而我们的连接就是流程变量的实际应用了-. 定义流程图 我们并不是所有的流程都是按一条的路径来走 ...

  7. JSP第四篇【EL表达式介绍、获取各类数据、11个内置对象、执行运算、回显数据、自定义函数、fn方法库】

    什么是EL表达式? 表达式语言(Expression Language,EL),EL表达式是用"${}"括起来的脚本,用来更方便的读取对象! EL表达式主要用来读取数据,进行内容的 ...

  8. Oracle日期时间操作大全

    本文出自:http://www.cnblogs.com/hl3292/archive/2010/11/03/1868159.html oracle sql日期比较: 共三部分: 第一部分:oracle ...

  9. oracle pl/sql 函数

    函数用于返回特定的数据,当建立函数时,在函数头部必须包含return子句.而在函数体内必须包含return语句返回的数据.我们可以使用create function来建立函数. 1).接下来通过一个案 ...

  10. Java 自增(++) 和 C语言中自增的区别

    在Java.c语言等高级语言中自增和自减的作用基本一致,都是变量自身加一或减一.下面我只对自增进行说明,自减是类似的. 自增运算符(++),有两种书写形式,一个是在变量前: ++ num; 另一种在变 ...