SAP 内表数据作为无格式附件excel发送邮件
更新时间:2023-11-06 12:42:01 阅读量: 教育文库 文档下载
- sap是什么意思呀推荐度:
- 相关推荐
form frm_send_mail .
data: objpack like sopcklsti1 occurs 2 with header line. data: objhead like solisti1 occurs 1 with header line. * DATA: OBJBIN LIKE SOLIX OCCURS 10 WITH HEADER LINE. data objbin like solisti1 occurs 0 with header line. data: objtxt like solisti1 occurs 10 with header line. data: reclist like somlreci1 occurs 5 with header line. data: objhex like solix occurs 10 with header line. data: doc_chng like sodocchgi1. data: tab_lines like sy-tabix.
data:sender_address like soextreci1-receiver value 'account@teamwisepower.com.cn'.
data: tmpstr type string .
data:i_record like solix occurs 0 with header line, \ filelen type i.
data: v_lines_bin_all type i , v_lines_bin type i .
data:lv_str type string.
data:lv_recname type ad_smtpadr .
data:lt_mail like standard table of zcfg_mail with header line . data :begin of lt_address occurs 0 , smtp_addr type ad_smtpadr , end of lt_address .
data :begin of lt_ccaddress occurs 0 , smtp_addr type ad_smtpadr , end of lt_ccaddress .
*** Mail Object
concatenate lv_str '贸易料检' into doc_chng-obj_descr separated by space.
*** 邮件正文
clear objtxt. objtxt = '你好,:'. append objtxt.
clear objtxt. append objtxt. clear objtxt.
验
批
监
控
objtxt = '附件是贸易料检验批清单,请查收,谢谢 '.
append objtxt.
describe table objtxt lines tab_lines. read table objtxt index tab_lines.
doc_chng-doc_size = ( tab_lines - 1 ) * 255 + strlen( objtxt ).
* Packing List For the E-mail Body objpack-head_start = 1. objpack-head_num = 0. objpack-body_start = 1.
objpack-body_num = tab_lines. objpack-doc_type = 'RAW'. append objpack.
**内表作为邮件附件
clear: tmpstr,i_record,i_record[].
perform itabtostr tables gt_xml using tmpstr.
perform strtorecord tables i_record using tmpstr filelen. append lines of i_record to objhex.\ describe table i_record lines v_lines_bin.
describe table objhex lines v_lines_bin_all.\
objhead = '贸易料检验批清单 '.
append objhead.
* Packing List For the E-mail Attachment objpack-transf_bin = 'X'. objpack-head_start = 1. objpack-head_num = 0. objpack-body_start = 1.
objpack-body_num = v_lines_bin.
objpack-obj_descr = '贸易料检验批清单'. objpack-obj_name = '贸易料检验批清单.xls' .
objpack-doc_type = 'XLS'.
objpack-doc_size = v_lines_bin_all * 255. append objpack.
**** 取发件人和收件人以及抄送人,
select *
into corresponding fields of table lt_mail from zcfg_mail
where progname = 'ZMMR074'.
if sy-subrc = 0 .
read table lt_mail index 1 .
split lt_mail-recname at '/' into table lt_address . split lt_mail-ccname at '/' into table lt_ccaddress . endif.
loop at lt_address. clear reclist .
reclist-receiver = lt_address-smtp_addr. * RECLIST-EXPRESS = 'X'. \发送快件 reclist-rec_type = 'U'.
translate reclist-receiver to upper case. append reclist. endloop.
loop at lt_ccaddress. clear reclist .
reclist-receiver = lt_ccaddress-smtp_addr. reclist-copy = 'X'. \抄送 reclist-rec_type = 'U'.
translate reclist-receiver to upper case. append reclist. endloop.
call function 'SO_DOCUMENT_SEND_API1' exporting
document_data = doc_chng put_in_outbox = 'X'
sender_address = sender_address ower.com.cn'
sender_address_type = 'SMTP'\ commit_work = 'X' tables
packing_list = objpack object_header = objhead * contents_bin = objbin contents_txt = objtxt contents_hex = objhex * OBJECT_PARA =
\* OBJECT_PARB =
receivers = reclist exceptions
too_many_receivers = 1 document_not_sent = 2 document_type_not_exist = 3 operation_no_authorization = 4 parameter_error = 5 x_error = 6 enqueue_error = 7 others = 8.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. else.
wait up to 2 seconds.
submit rsconn01 with mode = 'INT' and return. message '发送成功' type 'S'.
endif.
endform. \
*&---------------------------------------------------------------------*
*& Form itabtostr
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->INTAB text * -->OUTSTR text
*----------------------------------------------------------------------*
form itabtostr tables intab
using outstr type string.
data: tab type c value cl_abap_char_utilities=>horizontal_tab, enter(2) type c value cl_abap_char_utilities=>cr_lf, n type i.
data: begin of headtab occurs 0 , length type i , decimals type i,
type_kind type c, name(30) type c, end of headtab.
data descr_ref type ref to cl_abap_structdescr. field-symbols:
descr_ref ?= cl_abap_typedescr=>describe_by_data( intab ). loop at descr_ref->components assigning
describe table headtab lines n. loop at intab assigning
assign component sy-index of structure
read table headtab index sy-index.
if headtab-type_kind = 'I' or headtab-type_kind = 'P' or headtab-type_kind = 'F'. search str for '-'.
if sy-subrc = 0 and sy-fdpos <> 0. split str at '-' into str text1. condense str.
concatenate '-' str into str. else.
condense str. endif. else.
* SHIFT str LEFT DELETING LEADING '0' . endif.
concatenate str2 tab str into str2. enddo. shift str2.
concatenate outstr str2 enter into outstr. clear str2. endloop.
endform. \
*&---------------------------------------------------------------------*
*& Form STRTORECORD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_I_RECORD text * -->P_TMPSTR text * -->P_FILELEN text
*----------------------------------------------------------------------*
form strtorecord tables record using str len.
data:tmpbuffer type xstring.
call function 'SCMS_STRING_TO_XSTRING' exporting
text = str
mimetype = '\ * encoding = '8400' importing
buffer = tmpbuffer exceptions failed = 1 others = 2.
call function 'SCMS_XSTRING_TO_BINARY' exporting
buffer = tmpbuffer append_to_table = '' importing
output_length = len tables
binary_tab = record.
endform. \
*& Form STRTORECORD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_I_RECORD text * -->P_TMPSTR text * -->P_FILELEN text
*----------------------------------------------------------------------*
form strtorecord tables record using str len.
data:tmpbuffer type xstring.
call function 'SCMS_STRING_TO_XSTRING' exporting
text = str
mimetype = '\ * encoding = '8400' importing
buffer = tmpbuffer exceptions failed = 1 others = 2.
call function 'SCMS_XSTRING_TO_BINARY' exporting
buffer = tmpbuffer append_to_table = '' importing
output_length = len tables
binary_tab = record.
endform. \
正在阅读:
污水检测操作规程12-16
人音版小学音乐三年级下册《春天举行音乐会》教学设计01-10
市场调查大赛策划书1107-29
华为产品测试策略及验证计划模板04-09
空间缆索悬索桥的主缆线形分析_罗喜恒08-11
十大保命条例03-12
幼儿园2021年关工委工作计划书08-27
建筑施工现场十项达标基本标准(全套)09-23
- exercise2
- 铅锌矿详查地质设计 - 图文
- 厨余垃圾、餐厨垃圾堆肥系统设计方案
- 陈明珠开题报告
- 化工原理精选例题
- 政府形象宣传册营销案例
- 小学一至三年级语文阅读专项练习题
- 2014.民诉 期末考试 复习题
- 巅峰智业 - 做好顶层设计对建设城市的重要意义
- (三起)冀教版三年级英语上册Unit4 Lesson24练习题及答案
- 2017年实心轮胎现状及发展趋势分析(目录)
- 基于GIS的农用地定级技术研究定稿
- 2017-2022年中国医疗保健市场调查与市场前景预测报告(目录) - 图文
- 作业
- OFDM技术仿真(MATLAB代码) - 图文
- Android工程师笔试题及答案
- 生命密码联合密码
- 空间地上权若干法律问题探究
- 江苏学业水平测试《机械基础》模拟试题
- 选课走班实施方案
- 附件
- 发送
- 作为
- 邮件
- 格式
- 数据
- excel
- SAP
- 环保行政执法案卷评查存在问题
- 《数据库原理》实验讲义
- 辛弃疾词两首通案《水龙吟 登建康赏心亭》《永遇乐 京口北固亭怀古》 - 图文
- 单片机实验参考程序
- 谐波法设备状态数据诊断系统 - 图文
- 哲学与人生的复习题
- 2019秋高中地理 第五章 自然地理环境的整体性与差异性 第2节 自然地理环境的差异性导学案 新人教版必修1
- 金蝶BOS企业版V6.3.2 - 开发指南 - 管理门户 - Portlet开发 - 图文
- 汽车电器维修
- 建设项目成本构成及成本控制-毕业论文
- 石油生产节能技术研究团队
- 南京大学生命科学学院细胞生物学试卷2007-2008
- 结晶器保护渣的性能和特性
- 小学四年级上册科学课堂达标练习题及参考答案docx - 图文
- 世界现当代史历年试题及答案
- 变化信息发现 - 图文
- 《城市轨道交通车辆概论》期中考试试卷(1)
- 南京工程学院软件工程复习题答案
- 中国人“家”的观念
- 上海海事大学概率统计习题 题库