百度文库-SAP发送邮件
SAP系统邮件配置操作手册
SAP系统邮件配置操作手册1、配置参数文件运行事务码RZ10,创建参数:参数模板:icm/server_port_<*> = PROT=SMTP,PORT=<port>参数模板:is/SMTP/virt_host_<*> = <host>:<port>,<port>,...;A、创建参数名:icm/server_port_1 赋值:PROT=SMTP,PORT=25运行事务码:RZ10,如下图:在参数文件中选择:CE1_DVEBMGS07_ECC6IDES(子系统参数文件)备注:每个系统选择的参数文件均不同,与系统安装时名称填写相关,操作手册中的系统为CRM_IDES 7.01。
选择参数“CE1_DVEBMGS07_ECC6IDES”,同时将“编辑参数文件”选择成“扩展维护”如下图:点击“”,如下图:默认情况下已经有一个参数文件icm/server_port_0 = PORT=HTTP,PORT=XXXX(每个服务可能不一样),那么这里的<*>就是要根据你的参数文件的具体情况,如果已经有了_0,这里你就需要设成_1,以此类推,PORT一般设置成25,这里还有一个选项是TIMEOUT可以设定等待邮件服务器回复时间的最大值。
点击“”,输入“参数名称”、“参数值”,如下图:点击“”,如下图:最后点击保存。
B、创建参数名:is/SMTP/virt_host_0 赋值:*:25;定义虚拟邮件主机,主要用来接收邮件的,_<*>的设置通上。
要注意,参数值最后是有一个分号的。
如下图:完成后保存,激活,配置完需要重启服务,参数才能生效。
2、配置系统账户对于每一个Client,需要创建一个用户作为邮件的接收者。
用户类型:S(服务)参数文件:S_A.SCON(SAP 连接: 所有授权RFC 用户/ SAP 电话: 中心归档)通讯方式:RML 远程邮件A、对于每个用户来说,如果需要发送或者接收邮件的话,也需要在为其配置email地址,在su01中的general的E-mail中配置即可;B、如果把用户类型改为“系统用户”,第二天再登录系统时提示用对话用户登录。
SAP SMTP邮箱系统配置手册(发送邮件)
SAP SMTP 系统配置手册本手册包含以下内容:SAP SMTP 原理 SMTP 端口参数配置 SAPconnect 服务配置 SAPconnect 服务管理配置 邮件发送测试系统版本: NW7.4 EHP7 FOR SAP ERP 6.0 SAP NETWEAVER 7.4 SPS08作者 : 章 浩PUBLICDocument version: 1.00 – 2017-03-31QQ :334629265目录1.SAP SMTP原理 (2)2.SMTP端口参数配置(RZ10) (2)2.1配置参数 (2)2.2端口检查 (4)3.用户配置(SU01) (5)3.1创建用户 (5)3.2用户赋权 (6)3.3分配邮箱 (6)4. SAPconnect服务配置(SICF) (7)4.1执行SAPconnect维护 (7)4.2配置Host数据 (8)4.3配置登陆数据 (9)4.4激活SAPconnect服务 (10)5.SAPconnect服务管理配置(SCOT) (11)5.1创建服务节点 (11)5.2指定节点名称 (11)5.3指定主机名和端口 (12)5.4指定地址类型 (12)5.5指定地址区域 (13)5.6指定文档输出格式 (13)5.7取消进一步设置地址类型 (14)5.8设置发送失败等待时间 (14)5.9配置缺省域 (15)5.10配置发送作业 (16)6.邮件发送测试(SBWP) (17)7.SAP邮件发送请求监控(SOST) (20)8.常用外部邮箱服务器地址及端口 (20)1.SAP SMTP原理SAP系统允许发送和接收EMAIL邮件。
当然,为了实现邮件收发功能,我们需要在NETWEAVER ABAP平台上做一些配置。
配置之前,需要简单了解一下上图SAP SMTP原理。
1.外部SMTP服务器。
作为一个SMTP服务器来连接SAP SMTP发送者和接收者。
例如,263 SMTP服务器,GMAIL SMTP服务器,这些是本次配置的正式的邮件服务提供者。
SAP SMTP邮箱系统配置手册(发送邮件)
SAP SMTP 系统配置手册本手册包含以下内容:SAP SMTP 原理 SMTP 端口参数配置 SAPconnect 服务配置 SAPconnect 服务管理配置 邮件发送测试系统版本: NW7.4 EHP7 FOR SAP ERP 6.0 SAP NETWEAVER 7.4 SPS08作者 : 章 浩PUBLICDocument version: 1.00 – 2017-03-31QQ :334629265目录1.SAP SMTP原理 (2)2.SMTP端口参数配置(RZ10) (2)2.1配置参数 (2)2.2端口检查 (4)3.用户配置(SU01) (5)3.1创建用户 (5)3.2用户赋权 (6)3.3分配邮箱 (6)4. SAPconnect服务配置(SICF) (7)4.1执行SAPconnect维护 (7)4.2配置Host数据 (8)4.3配置登陆数据 (9)4.4激活SAPconnect服务 (10)5.SAPconnect服务管理配置(SCOT) (11)5.1创建服务节点 (11)5.2指定节点名称 (11)5.3指定主机名和端口 (12)5.4指定地址类型 (12)5.5指定地址区域 (13)5.6指定文档输出格式 (13)5.7取消进一步设置地址类型 (14)5.8设置发送失败等待时间 (14)5.9配置缺省域 (15)5.10配置发送作业 (16)6.邮件发送测试(SBWP) (17)7.SAP邮件发送请求监控(SOST) (20)8.常用外部邮箱服务器地址及端口 (20)1.SAP SMTP原理SAP系统允许发送和接收EMAIL邮件。
当然,为了实现邮件收发功能,我们需要在NETWEAVER ABAP平台上做一些配置。
配置之前,需要简单了解一下上图SAP SMTP原理。
1.外部SMTP服务器。
作为一个SMTP服务器来连接SAP SMTP发送者和接收者。
例如,263 SMTP服务器,GMAIL SMTP服务器,这些是本次配置的正式的邮件服务提供者。
关于SAP邮件[1]
一、SAP系统邮件设置事务代码:SCOT1、设置Default Domain: 菜单\设置\Default Domain2、配置SMTP节点,双击节点“SMTP”,弹出窗口在窗口里设置SMTP Connection的一些参数,然后点击下面的Internet设置,弹出窗口:3、设置后台作业:目的是为了周期性的定时发送邮件;选中节点“SMTP”,点击菜单\视图\职务,界面转跳到作业管理界面,点击”新建”按钮,进行作业创建,先录入作业名称:点击”勾”,确定后,在新弹出的界面里,选择一个程序变式:选中”SAP&CONNECTALL”,点击”release”按钮,设置作业开始时间及作业执行周期:点击”创建”后,状态栏显示:到此,邮件系统平台的设置完成。
二、ABAP发送邮件简单的样例:*&-----------------------------------------------------------* *& Report Z_EMAIL_TEST*&*&-----------------------------------------------------------* *&*&*&-----------------------------------------------------------*REPORT Z_EMAIL_TEST.* Data DeclarationsDATA: lt_mailsubject TYPE sodocchgi1.DATA: lt_mailrecipients TYPE STANDARD TABLE OF somlrec90 WITH HEADER LINE.DATA: lt_mailtxt TYPE STANDARD TABLE OF soli WITH HEADER LINE.* Recipientslt_mailrecipients-rec_type = 'U'.lt_mailrecipients-receiver = 'user@'.APPEND lt_mailrecipients .CLEAR lt_mailrecipients .* Subject.lt_mailsubject-obj_name = 'TEST'.lt_mailsubject-obj_langu = sy-langu.lt_mailsubject-obj_descr = 'Mail Subject'.* Mail Contentslt_mailtxt = 'This is a test mail'.APPEND lt_mailtxt. CLEAR lt_mailtxt.* Send MailCALL FUNCTION'SO_NEW_DOCUMENT_SEND_API1' EXPORTINGdocument_data = lt_mailsubject TABLESobject_content = lt_mailtxtreceivers = lt_mailrecipients EXCEPTIONStoo_many_receivers = 1document_not_sent = 2document_type_not_exist = 3operation_no_authorization = 4parameter_error = 5x_error = 6enqueue_error = 7OTHERS = 8.IF sy-subrc EQ0.COMMIT WORK.* Push mail out from SAP outboxSUBMIT rsconn01 WITH mode = 'INT'AND RETURN. ENDIF.//注:通过设定邮件程序后台周期作业,可以实现邮件预警功能!。
SAP NW7.4 发送外部邮件配置
SAP NW7.4发送外部邮件配置2016年3月18日版本控制限制:本文仅限于从SAP服务器发送邮件,不适用于接收外部邮件。
本次设置SAP 服务器为邮件客户端角色发送邮件为例。
一、SAP发外部邮件示意图SAP服务器位于企业内部网络的话,如果想发外部邮箱,目前来看有两种方式:1、SAP 服务器配置可以直接访问外网,将SAP服务器视作邮件客户端方式(NW731以后才支持)2、SAP服务器处于内网环境,找一台可以访问内网和外网的服务器,安装配置SMTP服务器,SAP服务器当做SMTP Server转发到该台服务器上,由该服务器转发到目标外部邮箱。
这种方式把SAP服务器当做SMTP Server处理。
二、SAP设置外发邮件步骤1、连接设置(激活SAPConnect)创建服务用户(任选)使用TCD:SU01创建服务类型用户,用户授权增加授权参数文件S_A.SCON,保存即可。
创建ICF服务。
这里需要说明,如果发邮件的SAP系统有多个集团,需要为每个集团创建ICF的SMTP 服务,但如果只有一个集团发邮件,则直接使用已经存在的SMTP服务即可,需要激活。
Host Data、Logon Data、Handle List按照要求输入即可。
激活现有的SMTP 服务选择“Yes’”2、设置ICM相关参数。
以客户端角色发送邮件,端口设置为25确实发现发布出去,暂时未追踪原因,设置为其他即可。
保存并激活参数文件,如果有多个实例的话,需要所有实例均设置重启。
ICM的参数激活,不需要重启整个系统,重启ICM即可。
使用TCD:SMICM,执行功能路径:Administration->ICM->Exit Hard->Local,几秒钟后ICM即重启完毕。
查看ICM参数路径GoTo->Parameters->Display。
3、设置SMTP Plug-in执行TCD:SCOT,使用向导创建SMTP Node输入Node名称和描述输入发件人SMTP服务器地址和端口,然后选择Setting,安装选项主要有两个方面,是否使用加密和用户密码输入。
SAP系统邮件功能配置
SAP系统邮件功能配置
相信SAP顾问或多或少都会接到⽤户要求SAP系统能够定时发送邮件的功能,定时将⽤户需要的信息已邮件的⽅式发送给固定的⼈员。
下⾯就来讲⼀下SAP发送邮件应该如何配置:
1、RZ10做配置:
is/SMTP/virt_host_0 值: *:25;
icm/server_port_1 值: PROT=SMTP,PORT=25
重启SAP服务
2、SICF激活:
3、SMICM配置:
如果这⾥的端⼝不是25000,则可以在菜单:服务⾥⾯先删除再创建!
设置默认域:
设置STMP连接:
输⼊发件邮箱的账户和密码
设置⾃动发送Mail
5、⽤户配置Su01⾥⾯设置:
6、其他功能
sost :所有待发送的邮件清单,也可以监视邮件发送状态,也可以在此页⾯发送邮件! sbwp:发送邮件功能
so01 :邮件/消息。
关于SAP邮件[1]
一、SAP系统邮件设置事务代码:SCOT1、设置Default Domain: 菜单\设置\Default Domain2、配置SMTP节点,双击节点“SMTP”,弹出窗口在窗口里设置SMTP Connection的一些参数,然后点击下面的Internet设置,弹出窗口:3、设置后台作业:目的是为了周期性的定时发送邮件;选中节点“SMTP”,点击菜单\视图\职务,界面转跳到作业管理界面,点击”新建”按钮,进行作业创建,先录入作业名称:点击”勾”,确定后,在新弹出的界面里,选择一个程序变式:选中”SAP&CONNECTALL”,点击”release”按钮,设置作业开始时间及作业执行周期:点击”创建”后,状态栏显示:到此,邮件系统平台的设置完成。
二、ABAP发送邮件简单的样例:*&-----------------------------------------------------------* *& Report Z_EMAIL_TEST*&*&-----------------------------------------------------------* *&*&*&-----------------------------------------------------------*REPORT Z_EMAIL_TEST.* Data DeclarationsDATA: lt_mailsubject TYPE sodocchgi1.DATA: lt_mailrecipients TYPE STANDARD TABLE OF somlrec90 WITH HEADER LINE.DATA: lt_mailtxt TYPE STANDARD TABLE OF soli WITH HEADER LINE.* Recipientslt_mailrecipients-rec_type = 'U'.lt_mailrecipients-receiver = 'user@'.APPEND lt_mailrecipients .CLEAR lt_mailrecipients .* Subject.lt_mailsubject-obj_name = 'TEST'.lt_mailsubject-obj_langu = sy-langu.lt_mailsubject-obj_descr = 'Mail Subject'.* Mail Contentslt_mailtxt = 'This is a test mail'.APPEND lt_mailtxt. CLEAR lt_mailtxt.* Send MailCALL FUNCTION'SO_NEW_DOCUMENT_SEND_API1' EXPORTINGdocument_data = lt_mailsubject TABLESobject_content = lt_mailtxtreceivers = lt_mailrecipients EXCEPTIONStoo_many_receivers = 1document_not_sent = 2document_type_not_exist = 3operation_no_authorization = 4parameter_error = 5x_error = 6enqueue_error = 7OTHERS = 8.IF sy-subrc EQ0.COMMIT WORK.* Push mail out from SAP outboxSUBMIT rsconn01 WITH mode = 'INT'AND RETURN. ENDIF.//注:通过设定邮件程序后台周期作业,可以实现邮件预警功能!。
SAP 内表数据作为无格式附件excel发送邮件
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@teamwi '.data: tmpstr type string .data:i_record like solix occurs 0 with header line, "solisti1filelen 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 Objectconcatenate 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 Bodyobjpack-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."objbin.describe table i_record lines v_lines_bin.describe table objhex lines v_lines_bin_all."objbinobjhead = '贸易料检验批清单 '.append objhead.* Packing List For the E-mail Attachmentobjpack-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_mailfrom zcfg_mailwhere 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'exportingdocument_data = doc_chngput_in_outbox = 'X'sender_address = sender_address "'qyyu@teamwisep 'sender_address_type = 'SMTP'"Bcommit_work = 'X'tablespacking_list = objpackobject_header = objhead* contents_bin = objbincontents_txt = objtxtcontents_hex = objhex* OBJECT_PARA =* OBJECT_PARB =receivers = reclistexceptionstoo_many_receivers = 1document_not_sent = 2document_type_not_exist = 3operation_no_authorization = 4parameter_error = 5x_error = 6enqueue_error = 7others = 8.if sy-subrc <> 0.message id sy-msgid type sy-msgty number sy-msgnowith 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. " FRM_SEND_MAIL*&---------------------------------------------------------------------**& Form itabtostr*&---------------------------------------------------------------------** text*----------------------------------------------------------------------** -->INTAB text* -->OUTSTR text*----------------------------------------------------------------------*form itabtostr tables intabusing 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: <comp_wa> type abap_compdescr ,<f_field> ,<f_intab> type any .data:str type string,str2 type string ,text1 type c.descr_ref ?= cl_abap_typedescr=>describe_by_data( intab ).loop at descr_ref->components assigning <comp_wa>.move-corresponding <comp_wa> to headtab.append headtab.endloop.describe table headtab lines n.loop at intab assigning <f_intab>.do n times.assign component sy-index of structure <f_intab> to <f_field>. str = <f_field>.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. " ITABTOSTR*&---------------------------------------------------------------------**& 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'exportingtext = strmimetype = '"text/html; charset=gb2312"'* encoding = '8400'importingbuffer = tmpbufferexceptionsfailed = 1others = 2.call function 'SCMS_XSTRING_TO_BINARY'exportingbuffer = tmpbufferappend_to_table = ''importingoutput_length = lentablesbinary_tab = record.endform. "strtorecord。
SAP系统邮件配置操作作业手册
SAP系统邮件配置操作作业手册
SAP系统邮件配置操作手册
1、配置参数文件
运行事务码RZ10,创建参数:
参数模板:icm/server_port_<*> = PROT=SMTP,PORT=<port>
参数模板:is/SMTP/virt_host_<*> = <host>:<port>,<port>,...;
A、创建参数名:icm/server_port_1 赋值:
PROT=SMTP,PORT=25
运行事务码:RZ10,如下图:
在参数文件中选择:
CE1_DVEBMGS07_ECC6IDES(子系统参数文件)
备注:每个系统选择的参数文件均不同,与系统安装时名称填写相关,操作手册中的系统为CRM_IDES 。
选择参数“CE1_DVEBMGS07_ECC6IDES”,同时将“编辑参数文件”选择成“扩展维护”如下图:
点击“”,如下图:
默认情况下已经有一个参数文件
icm/server_port_0 =
PORT=HTTP,PORT=XXXX(每个服务可能不一样),那么这里的<*>就是要根据你的参数文件的具体情况,如果已经有了_0,这里你就需要设成_1,以此类推,PORT一般设置成25,这里还有一个选项是TIMEOUT可以设定等待邮件服务器回复时间的最大值。
点击“”,输入“参数名称”、“参数值”,如下图:
点击“”,如下图:
最后点击保存。
SAP BW - 发送邮件
REPORT ZBW_SEND_MAIL_INFORM.DATA:LW_STRING TYPE STRING,MAILTO TYPE AD_SMTPADR,MAIN_TEXT TYPE BCSY_TEXT,TITLE TYPE SO_OBJ_DES,SEND_REQUEST TYPE REF TO CL_BCS,DOCUMENT TYPE REF TO CL_DOCUMENT_BCS,FAIL TYPE REF TO CX_BCS,RECIPIENT TYPE REF TO IF_RECIPIENT_BCS,GT_MAILTO TYPE STANDARD TABLE OF ZMAILTOUSER,GS_MAILTO TYPE ZMAILTOUSER,SENT_TO_ALL TYPE OS_BOOLEAN,BCS_EXCEPTION TYPE REF TO CX_BCS,BCS_MESSAGE TYPE STRING.START-OF-SELECTION."开始处理PERFORM FRM_GET_ADDRESS.CLEAR : GS_MAILTO.LOOP AT GT_MAILTO INTO GS_MAILTO.MAILTO = GS_MAILTO-MAILTO.CONDENSE MAILTO NO-GAPS.TITLE = '管理驾驶舱' && SY-DATUM && '执行状态'.CONDENSE TITLE NO-GAPS.CLEAR:LW_STRING,MAIN_TEXT,SEND_REQUEST,DOCUMENT,FAIL,RECIPIENT.CONCATENATE GS_MAILTO-NAME ',你好:''处理链:ZKP_PC_001 - 管理驾驶舱链已与' SY-DATUM SY-UZEIT '完成运行,请查收.'INTO LW_STRING.PERFORM FRM_SET_MIAL USING LW_STRING TITLE MAILTO.ENDLOOP.FORM FRM_GET_ADDRESS .SELECT *INTO TABLE GT_MAILTOFROM ZMAILTOUSER WHERE PROGRAMEID = 'ZBW_SEND_MAIL_INFORM'. ENDFORM. " FRM_GET_ADDRESS*&---------------------------------------------------------------------**& Form FRM_SET_MIAL*&---------------------------------------------------------------------** text*----------------------------------------------------------------------** -->I_STRING 文本政体* -->I_TITLE 标题* -->I_ADDRESS 邮箱地址*----------------------------------------------------------------------*FORM FRM_SET_MIAL USING I_STRING TYPE STRINGI_TITLE TYPE SO_OBJ_DESI_ADDRESS TYPE AD_SMTPADR.APPEND LW_STRING TO MAIN_TEXT.TRY.* 第一步: 创建发送请求SEND_REQUEST = CL_BCS=>CREATE_PERSISTENT( ).* 第二步: 创建整理发送内容DOCUMENT = CL_DOCUMENT_BCS=>CREATE_DOCUMENT(I_TYPE = 'RAW'I_TEXT = MAIN_TEXTI_SUBJECT = TITLE ).* 第三步: 添加邮件内容到发送请求SEND_REQUEST->SET_DOCUMENT( DOCUMENT ).* 第四步: 邮件地址转换RECIPIENT = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS( I_ADDRESS ).* 第五步: 添加邮件地址到发送请求SEND_REQUEST->ADD_RECIPIENT( RECIPIENT ).* 第六步: 正式发送并提交作业* Set E-mail sending optionsCALL METHOD SEND_REQUEST->SET_STATUS_ATTRIBUTESEXPORTINGI_REQUESTED_STATUS = 'E'I_STATUS_MAIL = 'E'.CALL METHOD SEND_REQUEST->SET_SEND_IMMEDIATELY( 'X' ).* Send documentCALL METHOD SEND_REQUEST->SEND(EXPORTINGI_WITH_ERROR_SCREEN = 'X'RECEIVINGRESULT = SENT_TO_ALL ).IF SENT_TO_ALL = 'X'.MESSAGE 'Mail sent successfully ' TYPE 'S'.ENDIF.COMMIT WORK.CATCH CX_BCS INTO BCS_EXCEPTION.BCS_MESSAGE = BCS_EXCEPTION->GET_TEXT( ).MESSAGE BCS_EXCEPTION TYPE 'E'.EXIT.ENDTRY.ENDFORM.。
SAP 将EXCEL作为附件发送Email
types: begin of xml_line,data(255) type x,end of xml_line.data:l_xml_table type table of xml_line.data:ls_itab type typ_itab.types: begin of xml_line,data(256) type x,end of xml_line.data: l_ixml type ref to if_ixml,l_streamfactory type ref to if_ixml_stream_factory, l_ostream type ref to if_ixml_ostream,l_renderer type ref to if_ixml_renderer,l_document type ref to if_ixml_document.data:l_element_root type ref to if_ixml_element,ns_attribute type ref to if_ixml_attribute,r_element_properties type ref to if_ixml_element,r_element type ref to if_ixml_element,r_worksheet type ref to if_ixml_element,r_table type ref to if_ixml_element,r_column type ref to if_ixml_element,r_row type ref to if_ixml_element,r_styles type ref to if_ixml_element,r_style type ref to if_ixml_element,r_borders type ref to if_ixml_element,r_border type ref to if_ixml_element,r_format type ref to if_ixml_element,r_cell type ref to if_ixml_element,r_data type ref to if_ixml_element,* l_xml_table TYPE TABLE OF xml_line,l_xml_size type i,l_rc type i,l_text(255) type c,l_value type string,l_type type string,p_type .field-symbols:<data_line> type any,<field> type any,<fwa> type any,<fs_flag> type any .data:p_tab like dd02l-tabname .data:data_tab type ref to data,gotstate type ddgotstate,dd03p_tab type table of dd03p,dd03p type dd03p.field-symbols:<data_tab> type standard table.field-symbols:<fs_field> like line of dd03p_tab.clear l_xml_table.define add_fieldcol.unassign: <fs_field>.clear dd03p.dd03p-fieldname = &1.dd03p-ddtext = &2.dd03p-outputlen = &3.dd03p-inttype = &4.dd03p-decimals = &5.dd03p-reptext = &6.dd03p-position = &7.append dd03p to dd03p_tab assigning <fs_field>.end-of-definition.add_fieldcol 'PRUEFLOS' '检验批' '8' 'C' '0' '' ''.add_fieldcol 'WERK' '工厂' '4' 'C' '0' '' ''.add_fieldcol 'CHARG' '批次' '6' 'C' '0' '' ''.add_fieldcol 'MATNR' '物料编码' '10' 'C' '0' '' ''.add_fieldcol 'MAKTX' '物料描述' '35' 'C' '0' '' ''.add_fieldcol 'LOSMENGE' '交检数量' '8' 'P' '3' '' ''.add_fieldcol 'GESSTICHPR' '抽检数量' '8' 'P' '3' '' ''.add_fieldcol 'ERSTELDAT' '收货日期' '8' 'C' '0' '' ''.add_fieldcol 'BUDAT' '过账日期' '8' 'C' '0' '' ''.add_fieldcol 'LAGORTCHRG' '库位' '4' 'C' '0' '' ''.add_fieldcol 'OBJNR' '工作指示编号' '8' 'C' '0' '' ''.add_fieldcol 'ERSTELLER' '创建者' '8' 'C' '0' '' ''.add_fieldcol 'TXT04' '系统状态' '35' 'C' '0' '' ''.* SORT dd03p_tab BY position .create data data_tab type standard table of typ_itab."STANDARD TABLE OF (P_TAB).* CREATE DATA DATA_TAB TYPE STANDARD TABLE OF (P_TAB).assign data_tab->* to <data_tab>.loop at gt_itab into ls_itab .append ls_itab to <data_tab>.endloop.* Creating a ixml factoryl_ixml = cl_ixml=>create( ).* Creating the dom object modell_document = l_ixml->create_document( ).* Create root node 'Workbook'l_element_root = l_document->create_simple_element(name = 'Workbook'* uri = 'urn:schemas-microsoft-com:office:spreadsheet' parent = l_document ).l_element_root->set_attribute(name = 'xmlns'value = 'urn:schemas-microsoft-com:office:spreadsheet' ).ns_attribute = l_document->create_namespace_decl(name = 'ss'prefix = 'xmlns'uri = 'urn:schemas-microsoft-com:office:spreadsheet' ). l_element_root->set_attribute_node( ns_attribute ). ns_attribute = l_document->create_namespace_decl(name = 'x'prefix = 'xmlns'uri = 'urn:schemas-microsoft-com:office:excel' ).l_element_root->set_attribute_node( ns_attribute ).* Create node for document properties.r_element_properties = l_document->create_simple_element(name = 'DocumentProperties'parent = l_element_root ).l_value = sy-uname.l_document->create_simple_element(name = 'Author'value = l_valueparent = r_element_properties ).* Stylesr_styles = l_document->create_simple_element(name = 'Styles'parent = l_element_root ).***** 抬头* Style for Header - Ice Blue, BOLDr_style = l_document->create_simple_element(name = 'Style'parent = r_styles ).r_style->set_attribute_ns(name = 'ID'prefix = 'ss'value = 'Header' ).r_format = l_document->create_simple_element(name = 'Font'parent = r_style ).r_format->set_attribute_ns(name = 'Bold'prefix = 'ss'value = '1' ).r_format = l_document->create_simple_element(name = 'Interior'parent = r_style ).r_format->set_attribute_ns(name = 'Color'prefix = 'ss'value = '#F2F2F2' ).r_format->set_attribute_ns(name = 'Pattern'prefix = 'ss'value = 'Solid' ).r_format = l_document->create_simple_element(name = 'Alignment'parent = r_style ).r_format->set_attribute_ns(name = 'Horizontal'prefix = 'ss'value = 'Center' ).r_format->set_attribute_ns(name = 'Vertical'prefix = 'ss'value = 'Center' ).r_format->set_attribute_ns(name = 'WrapText'prefix = 'ss'value = '1' ).**** 设置颜色格式***** 设置合计行格式r_style = l_document->create_simple_element(name = 'Style'parent = r_styles ).r_style->set_attribute_ns(name = 'ID'prefix = 'ss'value = 'RLine' ).r_format = l_document->create_simple_element( name = 'Interior'parent = r_style ).r_format->set_attribute_ns(name = 'Color'prefix = 'ss'value = '#FF0000' ).r_format->set_attribute_ns(name = 'Pattern'prefix = 'ss'value = 'Solid' ).* r_borders = l_document->create_simple_element( * name = 'Borders'* parent = r_style ).* r_format = l_document->create_simple_element( * name = 'Border'* parent = r_borders ).* r_format->set_attribute_ns(* name = 'Position'* prefix = 'ss'* value = 'Bottom' ).* r_format->set_attribute_ns(* name = 'LineStyle'* prefix = 'ss'* value = 'Dash' ).** r_format = l_document->create_simple_element( * name = 'Border'* parent = r_borders ).* r_format->set_attribute_ns(* name = 'Position'* prefix = 'ss'* value = 'Right' ).* r_format->set_attribute_ns(* name = 'LineStyle'* prefix = 'ss'* value = 'Dash' ).** r_format = l_document->create_simple_element( * name = 'Border'* parent = r_borders ).* r_format->set_attribute_ns(* name = 'Position'* prefix = 'ss'* value = 'Top' ).* r_format->set_attribute_ns(* name = 'LineStyle'* prefix = 'ss'* value = 'Dash' ).* r_format = l_document->create_simple_element( * name = 'Font'* parent = r_style ).* r_format->set_attribute_ns(* name = 'Bold'* prefix = 'ss'* value = '1' ).****** 设置颜色行是黄色r_style = l_document->create_simple_element(name = 'Style'parent = r_styles ).r_style->set_attribute_ns(name = 'ID'prefix = 'ss'value = 'YLine' ).r_format = l_document->create_simple_element( name = 'Interior'parent = r_style ).r_format->set_attribute_ns(name = 'Color'prefix = 'ss'value = '#FFFF00' ).r_format->set_attribute_ns(name = 'Pattern'prefix = 'ss'value = 'Solid' ).* Style for Dataloop at dd03p_tab into dd03p where fieldname <> 'MANDT'.case dd03p-inttype.when 'I' or 'N'.* General formatwhen 'P' or 'F'.* Numeric with specific number of decimalsr_style = l_document->create_simple_element(name = 'Style'parent = r_styles ).l_value = dd03p-fieldname.r_style->set_attribute_ns(name = 'ID'prefix = 'ss'value = l_value ).r_format = l_document->create_simple_element(name = 'NumberFormat'parent = r_style ).if dd03p-decimals > 0.l_value = '0.'.do dd03p-decimals times.concatenate l_value '0' into l_value.enddo.else.l_value = ''.endif.* l_value = '#,##0' .r_format->set_attribute_ns(name = 'Format'prefix = 'ss'value = l_value ).* WHEN 'D'.** General formatwhen others.* Fixed textr_style = l_document->create_simple_element(name = 'Style'parent = r_styles ).l_value = dd03p-fieldname.r_style->set_attribute_ns(name = 'ID'prefix = 'ss'value = l_value ).r_format = l_document->create_simple_element(name = 'NumberFormat'parent = r_style ).l_value = '@'.r_format->set_attribute_ns(name = 'Format'prefix = 'ss'value = l_value ).endcase.endloop .* Worksheetr_worksheet = l_document->create_simple_element(name = 'Worksheet 'parent = l_element_root ). r_worksheet->set_attribute_ns(name = 'Name'prefix = 'ss'value = 'Sheet1' ).* TABLE* <Table ss:ExpandedColumnCount="3" ss:ExpandedRowCount="1" x:FullCol umns="1" x:FullRows="1">r_table = l_document->create_simple_element(name = 'Table'parent = r_worksheet ).r_table->set_attribute_ns(name = 'FullColumns'prefix = 'x'value = '1' ).r_table->set_attribute_ns(name = 'FullRows'prefix = 'x'value = '1' ).* Column formatting ==>给对应列赋STYLE和WIDEloop at dd03p_tab into dd03p where fieldname <> 'MANDT'.* COLUMNNr_column = l_document->create_simple_element(name = 'Column'parent = r_table ).case dd03p-inttype.when 'I' or 'N'.* General formatwhen 'P' or 'F'.l_value = dd03p-fieldname.r_column->set_attribute_ns(name = 'StyleID'prefix = 'ss'value = l_value ).* WHEN 'D'.** General formatwhen others.l_value = dd03p-fieldname.r_column->set_attribute_ns(name = 'StyleID'prefix = 'ss'value = l_value ).* ENDIF.endcase.l_value = ( dd03p-outputlen + 5 ) * 5.condense l_value no-gaps.r_column->set_attribute_ns(name = 'Width'prefix = 'ss'value = l_value ).endloop."抬头* Column Headers Rowr_row = l_document->create_simple_element(name = 'Row'parent = r_table ).r_row->set_attribute_ns(name = 'StyleID'prefix = 'ss'value = 'Header' ).r_row->set_attribute_ns(name = 'AutoFitHeight'prefix = 'ss'value = '1' ).** Column nameloop at dd03p_tab into dd03p where fieldname <> 'MANDT'. * <Data>r_cell = l_document->create_simple_element(name = 'Cell'parent = r_row ).* ENDIF.l_value = dd03p-ddtext. "fieldname, scrtext_m etc.r_data = l_document->create_simple_element(name = 'Data'value = l_valueparent = r_cell ).r_data->set_attribute_ns(name = 'Type'prefix = 'ss'value = 'String' ).endloop.loop at <data_tab> assigning <data_line> .assign component 'LIGHT' of structure <data_line> to <fs_flag>.* ROWr_row = l_document->create_simple_element(name = 'Row'parent = r_table ).loop at dd03p_tab into dd03p where fieldname <> 'MANDT'.assign component dd03p-fieldname of structure <data_line> to <f ield>.check sy-subrc is initial.* <Cell>r_cell = l_document->create_simple_element(name = 'Cell'parent = r_row ).case dd03p-inttype.when 'I' or 'P' or 'F' or 'N'.l_type = 'Number'.* L_VALUE = <FIELD>.* CONDENSE L_VALUE NO-GAPS."负数时,将负号提前if <field> < 0.l_text = abs( <field> ).condense l_text.concatenate '-' l_text into l_value.* L_VALUE = L_TEXT.condense l_value no-gaps.else.l_value = <field>.if l_value is initial or l_value = 0.l_value = '-' .endif.condense l_value no-gaps.endif.when 'D' or 'T'.l_type = 'String'.if <field> = '00000000'.l_value = ''.else.write <field> to l_text.l_value = l_text.endif.when others.write <field> to l_text.shift l_text left deleting leading space.l_value = l_text.l_type = 'String'.endcase.** <DATA>if <fs_flag> = icon_led_red. " 异常通知单红色显示r_cell->set_attribute_ns(name = 'StyleID'prefix = 'ss'value = 'RLine' ).else.r_cell->set_attribute_ns(name = 'StyleID'prefix = 'ss'value = 'YLine' ).endif.r_data = l_document->create_simple_element(name = 'Data'value = l_valueparent = r_cell ). * Cell formatr_data->set_attribute_ns(name = 'Type'prefix = 'ss'value = l_type ).endloop.endloop.* CREATING A STREAM FACTORYl_streamfactory = l_ixml->create_stream_factory( ).* Connect internal XML table to stream factoryl_ostream = l_streamfactory->create_ostream_itable( table = l_xml_t able ).* RENDERING THE DOCUMENTl_renderer = l_ixml->create_renderer( ostream = l_ostreamdocument = l_document ).l_rc = l_renderer->render( ).* SAVING THE XML DOCUMENTl_xml_size = l_ostream->get_num_written_raw( ).***下载本地文件call method cl_gui_frontend_services=>gui_downloadexportingbin_filesize = l_xml_sizefilename = 'D:\xml\ZQMR022.xls'filetype = 'BIN'changingdata_tab = l_xml_tableexceptionsothers = 24.if sy-subrc <> 0.message id sy-msgid type sy-msgty number sy-msgnowith sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.endif.*****发送邮件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: 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: l_num(3).data: subj_date(10) type c.data:lv_char type string .data:mailtitle(100) type c.data:g_vendername like lfa1-name1.data g_lifnr like ekko-lifnr.data: g_adrnr like lfa1-adrnr.data:sender_address like soextreci1-receiver.data:wa_xml type xml_line.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 'Weekly Sales Report' INTO doc_chng-obj_descr SEPARATED BY space.doc_chng-obj_descr = '检验批监控' .*** 邮件正文clear objtxt.objtxt = '你好:'.append objtxt.clear objtxt.append objtxt.clear objtxt.objtxt = '附件是存在异常检验批监控数据,请查收并及时处理,谢谢 '.append objtxt.clear objtxt.lv_char = '其中异常总数量: ' && gv_line && ';' && '未检验数量:' && gv_wj&& ';' && '异常数量:' && gv_yc .objtxt = lv_char .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 Bodyobjpack-head_start = 1.objpack-head_num = 0.objpack-body_start = 1.objpack-body_num = tab_lines.objpack-doc_type = 'RAW'.append objpack.**内表作为邮件附件** Creation of the Document Attachmentloop at l_xml_table into wa_xml.clear objhex.objhex-line = wa_xml-data.append objhex.endloop.describe table objhex lines tab_lines."objbinobjhead = '检验批监控'.append objhead.* Packing List For the E-mail Attachmentobjpack-transf_bin = 'X'.objpack-head_start = 1.objpack-head_num = 0.objpack-body_start = 1.objpack-body_num = tab_lines.objpack-obj_descr = '检验批监控异常数据'.objpack-obj_name = '检验批监控.xls' .objpack-doc_type = 'XLS'.objpack-doc_size = tab_lines * 255.append objpack.**** 取发件人和收件人以及抄送人,sender_address = '*************************.cn'.select *into corresponding fields of table lt_mailfrom zcfg_mailwhere progname = 'ZQMR022'.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'exportingdocument_data = doc_chngput_in_outbox = 'X'sender_address = sender_address "'qyyu@teamwisep 'sender_address_type = 'SMTP'"Bcommit_work = 'X'tablespacking_list = objpackobject_header = objhead* contents_bin = objbincontents_txt = objtxtcontents_hex = objhex* OBJECT_PARA =* OBJECT_PARB =receivers = reclistexceptionstoo_many_receivers = 1document_not_sent = 2document_type_not_exist = 3operation_no_authorization = 4parameter_error = 5x_error = 6enqueue_error = 7others = 8.if sy-subrc <> 0.message id sy-msgid type sy-msgty number sy-msgnowith 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.。
SAP采购订单核发完自动发邮件需求开发说明
最终确认:
职责/角色
签名
日期
关键用户
顾问
项目经理(甲方)
项目经理(乙方)
开发需求说明书
基础信息:
模块:
MM
说明书编号:
022
功能名称:
采购订单核发完自动发邮件功能
程序名:
事务代码:
更改记录:
版本
更新日期
更改人
更改内容
需求确认:
职责/角色
签名
日期
关键用户
顾问
项目经理(甲方)
项目经理(乙方)
报表/功能目标:
采购订单核发完自动发邮件
优先级别:
□高 □中 □低
频率:
□每天 □每周 □每月 □其他(随时)
Z332
标准件采购订单
采购
自动发邮件
Z333
生产辅料采购订单
采购
自动发邮件
Z334
安全库存采购订单
采购
自动发邮件
Z335
全工序外购件采购订单
外发
自动
Z337
多工序外发采购订单
外发
自动发邮件
Z339
精密带工序外发采购订单
外发
自动发邮件
2.供应商主数据根据邮箱地址自动发邮件给供应商:
执行模式:
□在线 □后台
开发天数:
计划2天 ; 实际 天
业务需求:
一. 开发概要
二.功能需求分析
1.采购订单最后一级审批完,针对供应商主数据维护了邮箱地址,将自动发邮件给供应商和采购员
三. 使用范围
1.采购订单类型自动发邮件功能如下:
订单类型
订单订单
系统制作部门
SAP配置邮件服务器
SAP配置邮件服务器1·介绍本文档旨在提供一个详细的指南,以帮助您配置SAP系统与邮件服务器的集成。
通过将邮件服务器与SAP系统集成,您可以实现SAP系统中的邮件通知功能,例如工作流审批通知、提醒、报警等。
2·准备工作在开始配置之前,请确保您已准备以下内容:●详细了解您邮件服务器的配置信息,包括服务器地质、端口、认证方式等。
●具备SAP系统管理员权限。
●确保网络连接正常,能够与邮件服务器通信。
3·配置邮件服务器参数步骤1:登录SAP系统使用SAP系统管理员账号登录SAP系统。
步骤2:进入SCOT事务在SAP Easy Access菜单中,输入事务代码“SCOT”并按Enter键。
步骤3:配置外部邮件服务器3·1 在SCOT事务中,选择“Settings”菜单下的“Configuration”选项。
3·2 在“Default domn”字段中输入您的默认域名。
3·3 在“Nodes”标签页下,选择“SMTP”节点。
3·4 在SMTP节点下选择“SMTP Connect”配置。
3·5 在“Smart Host”字段中输入您的邮件服务器的主机名。
3·6 在“Port number”字段中输入您的邮件服务器的端口号。
3·7 在“Authentication”字段中选择适当的认证方式。
3·8 在“User”字段中输入您的邮件服务器的用户名。
3·9 在“Password”字段中输入您的邮件服务器的密码。
3·10 保存配置更改。
4·测试邮件服务器连接步骤1:选择SCOT事务回到SAP Easy Access菜单中,重新进入SCOT事务。
步骤2:测试邮件发送4·1 选择“Goto”菜单下的“Settings”选项。
4·2 选择“Addresses”选项。
SAP邮件发送
一、***************************************在SAP中我们可以配置STMP邮件功能,可以通过SOST来查看邮件状态,在编码中可用FM SO_DOCUMENT_SEND_API1 、SO_NEW_DOCUMENT_ATT_SEND_API1通过编码的方式来发送邮件以及邮件附件。
在定义附件表时用solisti1,其长度为Char255,实际中我们导出的每一行记录都会超出这个长度。
对XLS格试的附件我们可以用Excel的分隔标签来解决这个问题,对于文字乱码我们可以在附件加charset=utf-16le解决此类问题。
同样,也适用于其他类似的乱码问题。
constants: c_tab type c value cl_abap_char_utilities=>horizontal_tab,c_cret type c value cl_abap_char_utilities=>cr_lf,c_mimetype type char64value 'APPLICATION/MSEXCEL;charset=utf-16le'.data: v_xattach type xstring,it_binary_attach type solix_tab.*---------------------------------------------------------------------------------* Convert the internal data to XString*----------------------------------------------------------------------------------data: lc_descr_ref type ref to cl_abap_structdescr,lv_value type char128,lv_temp type string,lv_mid type string,lv_tabix type sy-tabix.field-symbols: <fs_intable> type any.field-symbols: <intable_wa> type abap_compdescr.loop at it_table.lv_tabix = sy-tabix.clear lv_temp.lc_descr_ref ?= cl_abap_typedescr=>describe_by_data( it_table ).loop at lc_descr_ref->components assigning <intable_wa>.assign component sy-tabix of structure in_table to <fs_table>.lv_value = <fs_table>.condense lv_value.if sy-tabix = 1.lv_temp = lv_value.continue.endif.concatenate lv_temp lv_valueinto lv_temp separated by c_tab.endloop.concatenate lv_mid lv_temp c_cret into lv_mid.endloop.* Convert string to xstring type* 'APPLICATION/MSEXCEL;charset=utf-16le'call function 'SCMS_STRING_TO_XSTRING'exportingtext = lv_midmimetype = c_mimetypeimportingbuffer = v_xattachexceptionsfailed = 1others = 2.* Add the file header for utf-16le. .if sy-subrc = 0.concatenate cl_abap_char_utilities=>byte_order_mark_littlev_xattach into v_xattach in byte mode.endif.call function 'SCMS_XSTRING_TO_BINARY'exportingbuffer = v_xattachtablesbinary_tab = it_binary_attach.*---------------------------------------------------------------------------------*Send Email*----------------------------------------------------------------------------------data: lv_title type so_obj_des, " Email Titlelv_email type adsmtp-smtp_addr, " Receiverlv_attitle type char50. " Attachment Titledata: send_request type ref to cl_bcs,document type ref to cl_document_bcs,conlengths typeso_obj_len,html type table of w3html,sender_id type ref to if_sender_bcs,recipient type ref to if_recipient_bcs,cc_recipient type ref to if_recipient_bcs,sent_to_all typeos_boolean,bcs_exception type ref to cx_bcs,bcs_message type string.clear: lv_email,lv_title,html. " Email Body Content with html formattry.* request email functionclear send_request.send_request = cl_bcs=>create_persistent( ).* Create the content of emailclear document .document = cl_document_bcs=>create_document(i_type = 'HTM'i_text = htmli_length = conlengthsi_subject = lv_title ).* Add Attachmentcall method document->add_attachmentexportingi_attachment_type = 'XLS'i_attachment_subject = lv_attitlei_att_content_hex = it_binary_attach.* Add document to send requestcall method send_request->set_document( document ).clear recipient.recipient =cl_cam_address_bcs=>create_internet_address( lv_email ). * Add recipient with its respective attributes to send request call method send_request->add_recipientexportingi_recipient = recipienti_express = 'X'.* E-mailcall method send_request->set_status_attributesexportingi_requested_status = 'E'i_status_mail = 'E'.call method send_request->set_send_immediately( 'X' ).* Send documentcall method send_request->send(exportingi_with_error_screen = 'X'receivingresult = sent_to_all ).if sent_to_all = 'X' and sy-batch <> 'X'.message 'Send Successfully' type 'I'.endif.commit work.catch cx_bcs into bcs_exception.bcs_message = bcs_exception->get_text( ).if sy-batch <> 'X'.message bcs_exception type 'E'.else.write: bcs_message.endif.exit.endtry.二、SAP OFFCIE功能发送邮件SAP做为自成一体的系统,其开发环境有着丰富的资源,其中就包括发送邮件的SAP Office 组件。
SAP配置邮件服务器
SAP配置邮件服务器配置SAP邮件服务器⒈概述在SAP系统中配置邮件服务器是为了能够发送和接收电子邮件通知。
本文档将详细介绍如何配置SAP系统与邮件服务器的集成。
⒉准备工作在开始配置之前,需要以下准备工作:●确保已经安装并成功运行了邮件服务器软件。
●获取邮件服务器的主机名、端口号、用户名和密码等必要信息。
●确保SAP系统具备邮件服务器访问的网络连接。
⒊配置SAP系统参数⑴邮件服务器配置在SAP系统中设置邮件服务器参数的步骤如下:⒈进入SAP系统,使用SAP管理员账户登录。
⒉使用事务码 SOST 打开输出管理。
⒊在菜单栏选择“编辑”->“设置”->“输出设备”。
⒋在邮件设置中输入邮件服务器主机名、端口号等相关信息。
⒌保存。
⑵邮件通知配置为了能够使SAP系统发送电子邮件通知,需要进行以下配置:⒈进入SAP系统,使用SAP管理员账户登录。
⒉使用事务码 SPRO 打开SAP Reference IMG。
⒊导航至“SAP NetWeaver”->“应用服务器”->“基本服务”->“输出管理”->“输出控制”。
⒋双击“设置输出使用的条件和配置输出类型”。
⒌找到需要配置的输出类型(例如订单确认或工作流通知),并进行相应的设置。
⒍在通信窗口(TCODE SCOT)中选择“SMTP”节点,设置相关的邮件文本和适用条件。
⒎保存。
⒋测试邮件发送与接收为了验证配置的准确性,可以进行以下测试步骤:⒈在SAP系统中创建一个测试订单,触发相关的电子邮件通知。
⒉检查SAP系统输出管理的队列,并确保邮件已从队列中发送。
⒊检查邮件服务器,确认邮件已成功发送。
⒋在一个外部邮箱中检查,确认已成功收到SAP系统发送的邮件。
附件:无法律名词及注释:无。
sap sost参数
sap sost参数
SAP系统中的SOST参数指的是"Send Requests",它是用于管理和监视发出的邮件请求的工具。
通过SOST参数,用户可以查看和管理已发送但尚未被接收的邮件请求,也可以重新发送或删除这些请求。
在SAP中,用户可以通过输入SOST命令来进入SOST参数设置界面。
在这个界面上,用户可以执行多种操作,比如查看特定时间段内的邮件发送情况、查看特定收件人的邮件发送情况、重新发送失败的邮件请求、删除不需要的邮件请求等。
除了基本的邮件发送管理功能,SOST参数还提供了一些高级功能,比如邮件发送日志记录、邮件发送状态跟踪、邮件发送错误处理等。
通过这些功能,用户可以更好地监控和管理系统中的邮件发送情况,及时发现和解决邮件发送中的问题。
总之,SOST参数在SAP系统中扮演着重要的角色,它为用户提供了一个方便而有效的方式来管理和监控系统中的邮件发送请求,帮助用户更好地维护和管理系统的邮件发送功能。
SAP邮件发送
SAP邮件发送此邮件发送为附件XLS⽂档,也可将参数设置为PDF,可发送PDF附件。
⼀、新建⾃定义表,如下: 存储邮箱地址。
若邮箱地址可直接从系统抓取则可忽略⼆、数据定义****-----------------------------------邮件发送---------------------------------------------CONSTANTS:gc_tab TYPE c VALUE cl_bcs_convert=>gc_tab, "CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TABgc_crlf TYPE c VALUE cl_bcs_convert=>gc_crlf. "CL_ABAP_CHAR_UTILITIES=>CR_LFDATA: i_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,i_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE, "receiversi_sendmail LIKE zsendmail OCCURS 0 WITH HEADER LINE,i_contents_txt LIKE solisti1 OCCURS 0 WITH HEADER LINE, "ASCII contents of object and attachments i_contents_hex LIKE solix OCCURS 0 WITH HEADER LINE, "Binary contents of object and attachments i_contents_bin LIKE solisti1 OCCURS 0 WITH HEADER LINE,i_object_header LIKE solisti1 OCCURS 0 WITH HEADER LINE, "attachments namew_doc_data LIKE sodocchgi1.DATA: c_mimetype TYPE char64 VALUE 'APPLICATION/MSEXCEL;charset=utf-16le'.DATA: v_xattach TYPE xstring.DATA: lv_string TYPE string.DATA: tab_lines LIKE sy-tabix,w_sent_all(1) TYPE c,w_error TYPE sy-subrc.DATA:num1 TYPE i.三、相关代码START-OF-SELECTION.PERFORM getdata.DESCRIBE TABLE gt_data LINES num1.IF num1 NE 0.IF sy-batch = 'X'.PERFORM send_mail.ELSE.PERFORM display_data.ENDIF.ENDIF.IF num1 EQ 0.MESSAGE '没有符合条件的数据 ' TYPE 'I'.ENDIF.FORM send_mail .PERFORM get_send_mail.***define mail main context****PERFORM define_mail_header.***dfine attachment*******************PERFORM define_mail_attachment.***get mail receiver*****************PERFORM get_receivers.*Send email message, although is not sent from SAP until mail send*program has been executed(rsconn01)PERFORM send_email_message.ENDFORM.FORM get_send_mail.SELECT * FROM zsendmailINTO CORRESPONDING FIELDS OF TABLE i_sendmail.IF matnr[] IS INITIAL .DELETE i_sendmail WHERE ztype NE '1'."成品ELSE.DELETE i_sendmail WHERE ztype NE '2'."复配料ENDIF.ENDFORM. " GET_SPFLI_DATAFORM define_mail_header .DATA: tmp_date LIKE sy-datum.DATA: tmp_char(30).tmp_date = sy-datum.CONCATENATE 'Overdue Batch ' sy-datum INTO tmp_char.********define subject and priority************IF matnr[] IS INITIAL.w_doc_data-obj_descr = '成品库存货龄表'. "Email Subject.ELSE.w_doc_data-obj_descr = '复配料库存货龄表'. "Email Subject.ENDIF.w_doc_data-priority = 1. "mail PRIORITY¡A 1 is highestw_doc_data-obj_langu = sy-langu.w_doc_data-obj_name = 'OFFER'. "Name of document..w_doc_data-sensitivty = 'O'. "Document sensitivity.********mail main context***********************i_contents_txt = '各位主管、同仁:'.APPEND i_contents_txt.i_contents_txt = ' '.APPEND i_contents_txt.IF matnr[] IS INITIAL.i_contents_txt = ' 附件为成品库存货龄表!'.ELSE.i_contents_txt = ' 附件为复配料库存货龄表!'.ENDIF.APPEND i_contents_txt.i_contents_txt = ' 此邮件为系统发送,不需要回复'.APPEND i_contents_txt.i_contents_txt = ' 如果您有任务疑问,请联系SAP管理员'.APPEND i_contents_txt.i_contents_txt = ' '.APPEND i_contents_txt.i_contents_txt = tmp_date.APPEND i_contents_txt.DESCRIBE TABLE i_contents_txt LINES tab_lines.READ TABLE i_contents_txt INDEX tab_lines.w_doc_data-doc_size = ( tab_lines - 1 ) * 255 + strlen( i_contents_txt ). ********count lines by man context*************CLEAR i_packing_list-transf_bin.i_packing_list-transf_bin = space. "ASCII format/binary formati_packing_list-head_start = 1.i_packing_list-head_num = 0.i_packing_list-body_start = 1.i_packing_list-body_num = tab_lines.i_packing_list-doc_type = 'RAW'.APPEND i_packing_list.ENDFORM. " DEFINE_MAIL_HEADERFORM define_mail_attachment .CONCATENATE lv_string'物料描述' gc_tab'物料组' gc_tab'⼯⼚' gc_tab'库存描述' gc_tab'批次' gc_tab'⾮限制库存数量' gc_tab'冻结库存数量' gc_tab'质检库存数量' gc_tab'单位' gc_tab'保质期(天)' gc_tab'货龄天数' gc_tab'距离失效天数' gc_crlfINTO lv_string.IF matnr[] IS NOT INITIAL.SELECT * FROM zmm028 INTO TABLE @DATA(lt_zmm028). SORT lt_zmm028 BY matnr.ENDIF.LOOP AT gt_data INTO gs_data ."增加前导零CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'EXPORTINGinput = gs_data-matnrIMPORTINGoutput = gs_data-matnr.IF matnr[] IS INITIAL.CASE gs_data-extwg.WHEN '101' OR '103' OR '104' OR '106' OR '107' OR '190'. CHECK gs_data-hlts > 7.WHEN '102'."3CHECK gs_data-hlts > 3.WHEN '105'."30CHECK gs_data-hlts > 30.WHEN OTHERS.CONTINUE.ENDCASE.ELSE.READ TABLE lt_zmm028 INTO DATA(ls_zmm028)WITH KEY matnr = gs_data-matnr .IF sy-subrc NE 0.CONTINUE.ELSE.CHECK gs_data-hlts >= ls_zmm028-zday.ENDIF.ENDIF."去除前导零CALL FUNCTION 'CONVERSION_EXIT_MATN1_OUTPUT' EXPORTINGinput = gs_data-matnrIMPORTINGoutput = gs_data-matnr.lv_string = lv_string &&gs_data-maktx && gc_tab &&gs_data-ewbez && gc_tab &&gs_data-werks && gc_tab &&gs_data-lgobe && gc_tab &&gs_data-charg && gc_tab &&gs_data-clabs && gc_tab &&gs_data-cspem && gc_tab &&gs_data-cinsm && gc_tab &&gs_data-meins && gc_tab &&gs_data-mhdhb && gc_tab &&gs_data-hlts && gc_tab &&gs_data-sxts && gc_crlf.ENDLOOP.* Convert string to xstring type* 'APPLICATION/MSEXCEL;charset=utf-16le'CALL FUNCTION 'SCMS_STRING_TO_XSTRING'EXPORTINGtext = lv_stringmimetype = c_mimetypeIMPORTINGbuffer = v_xattachEXCEPTIONSfailed = 1OTHERS = 2.* Add the file header for utf-16le. .IF sy-subrc = 0.CONCATENATE cl_abap_char_utilities=>byte_order_mark_littlev_xattach INTO v_xattach IN BYTE MODE.ENDIF.CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'EXPORTINGbuffer = v_xattachTABLESbinary_tab = i_contents_hex.***set attachment name, count size*******************DESCRIBE TABLE gt_data LINES tab_lines.tab_lines = tab_lines .i_packing_list-transf_bin = 'X'.i_packing_list-head_start = 1.i_packing_list-head_num = 0.i_packing_list-body_start = 1.i_packing_list-body_num = tab_lines.i_packing_list-doc_type = 'XLS'.i_packing_list-obj_name = 'ATTACHMENT'.i_packing_list-obj_descr = 'Finished Stock'. "成品库存货龄表修改为英⽂i_packing_list-doc_size = tab_lines * 255.APPEND i_packing_list.ENDFORM. " DEFINE_MAIL_ATTACHMENTFORM get_receivers .* Add the recipients email addressCLEAR i_receivers.REFRESH i_receivers.* SELECT * FROM zszmail.LOOP AT i_sendmail.* I_RECEIVERS-RECEIVER = 'pandeng@'."Email Addressi_receivers-receiver = i_sendmail-receiver.i_receivers-rec_type = 'U'. "Internet addressi_receivers-notif_read = ''.i_receivers-com_type = 'INT'.i_receivers-notif_del = ''.i_receivers-notif_ndel = ''.APPEND i_receivers.ENDLOOP.* ENDSELECT.ENDFORM. " GET_RECEIVERSFORM send_email_message.DATA: w_subrc LIKE sy-subrc.* Call the FM to post the message to SAPMAILCALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'EXPORTINGdocument_data = w_doc_data "Attributes of new documentput_in_outbox = 'X' "Flag: Move document to outbox after sendcommit_work = 'X' "An explicit COMMIT WORK is to be setIMPORTINGsent_to_all = w_sent_allTABLESpacking_list = i_packing_list "Information about structure of data tables object_header = i_object_headercontents_hex = i_contents_hexcontents_txt = i_contents_txt "ASCII contents of object and attachments receivers = i_receivers "Document recipients with send attributes EXCEPTIONStoo_many_receivers = 1document_not_sent = 2document_type_not_exist = 3operation_no_authorization = 4parameter_error = 5x_error = 6enqueue_error = 7OTHERS = 8.w_subrc = sy-subrc.WAIT UP TO 2 SECONDS.IF w_subrc EQ 0.SUBMIT rsconn01 WITH mode = 'INT' WITH output = spaceAND RETURN.ENDIF.ENDFORM. " SEND_EMAIL_MESSAGE。
SAP 发邮件
发送Emailsap发送Email方法﹕1﹐从smartform中获取返回的内表data: control_parameters TYPE ssfctrlop,job_output_info TYPE ssfcrescl,job_output_options TYPE ssfcresop,i_pdf_tab LIKE TABLE OF tline WITH HEADER LINE.control_parameters-getotf = 'X'.CALL FUNCTION f_nameEXPORTINGcontrol_parameters = control_parametersIMPORTINGjob_output_info = job_output_infojob_output_options = job_output_options .2,将返回的OFT转到PDF内格式内表CALL FUNCTION 'CONVERT_OTF'EXPORTINGformat = 'PDF'IMPORTINGbin_filesize = g_filesizeTABLESotf = job_output_info-otfdatalines = i_pdf_tabEXCEPTIONSerr_max_linewidth = 1err_format = 2err_conv_not_possible = 3OTHERS = 4.IF p_s1 = 'X' .PERFORM send_mail TABLES i_pdf_tab.ELSE .PERFORM send_mail2 TABLES i_pdf_tab .ENDIF.方法1FORM send_mail TABLES pdf_tab STRUCTURE tline.DATA: objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE. DATA: objhead LIKE solisti1 OCCURS 0 WITH HEADER LINE. DATA: objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE. DATA: objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE. DATA: reclist LIKE somlreci1 OCCURS 5 WITH HEADER LINE. DATA: doc_chng LIKE sodocchgi1.DATA: righe_attachment TYPE i.DATA: righe_testo TYPE i.DATA: transfer_bin TYPE sx_boolean.DATA: buffer TYPE string.DATA: li_subrc TYPE i .DATA: lines LIKE TABLE OF tline WITH HEADER LINE,header LIKE thead.CLEAR: reclist, reclist[],objhead, objhead[],objtxt, objtxt[],objbin, objbin[],objpack, objpack[].* convert to PDFCALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'TABLEScontent_in = pdf_tab[]content_out = objbin[]EXCEPTIONSerr_line_width_src_too_long = 1err_line_width_dst_too_long = 2err_conv_failed = 3OTHERS = 4.* Assign email body textobjtxt = '邮件内容 .'.APPEND objtxt.objtxt = 'send by SO_NEW_DOCUMENT_ATT_SEND_API1 '.APPEND objtxt.DESCRIBE TABLE objtxt LINES righe_testo.READ TABLE objtxt INDEX righe_testo.* Document attributedoc_chng-obj_name = 'AABB'.doc_chng-expiry_dat = sy-datum + 10.doc_chng-obj_descr = '邮件标题'.doc_chng-obj_langu = 'E'.doc_chng-sensitivty = 'O'.doc_chng-doc_size = ( righe_testo - 1 ) * 255 + STRLEN( objtxt ). CLEAR objpack-transf_bin.objpack-head_start = 1.objpack-head_num = 0.objpack-body_start = 1.objpack-body_num = righe_testo.objpack-doc_type = 'RAW'.APPEND objpack.DESCRIBE TABLE objbin LINES righe_attachment. objpack-transf_bin = 'X'.objpack-head_start = 1.objpack-head_num = 1.objpack-body_start = 1.objpack-body_num = righe_attachment.objpack-doc_type = 'PDF'.objpack-obj_name = 'PO'.objpack-obj_descr = '附件名称.PDF' .objpack-doc_size = righe_attachment * 255.APPEND objpack.CLEAR reclist.reclist-express = 'X'.reclist-rec_type = 'U'.reclist-notif_del = 'X'. "request delivery notification reclist-notif_ndel = 'X'. "request not delivered notification reclist-receiver = 'AABBCC@'.APPEND reclist.CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1' EXPORTINGdocument_data = doc_chngput_in_outbox = 'X'TABLESpacking_list = objpackobject_header = objheadcontents_bin = objbincontents_txt = objtxtreceivers = reclistEXCEPTIONStoo_many_receivers = 1document_not_sent = 2document_type_not_exist = 3operation_no_authorization = 4parameter_error = 5x_error = 6enqueue_error = 7OTHERS = 8.ENDFORM. " SEND_MAIL*---------------------------------------------------------------------* * FORM send_mail2 : 第二种方法*---------------------------------------------------------------------*FORM send_mail2 TABLES pdf_tab STRUCTURE tline. DATA: ls_hd_change LIKE sood1 ,li_colines TYPE i ,"邮件内容行数li_pdflines TYPE i,"PDF内表行数li_subrc TYPE i .DATA: it_content LIKE soli OCCURS 0 WITH HEADER LINE , it_packlist LIKE soxpl OCCURS 0 WITH HEADER LINE ,it_receivers LIKE soos1 OCCURS 0 WITH HEADER LINE , objbin LIKE soli OCCURS 10 WITH HEADER LINE. REFRESH: objbin[] ,it_content[] ,it_packlist[] .* 附件处理* Convert PDF to 邮件附件CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE' TABLEScontent_in = pdf_tab[]content_out = objbin[]EXCEPTIONSerr_line_width_src_too_long = 1err_line_width_dst_too_long = 2err_conv_failed = 3OTHERS = 4.DESCRIBE TABLE objbin LINES li_pdflines .*邮件内容REFRESH : it_content .it_content-line = '邮件内容'.APPEND it_content .DESCRIBE TABLE it_content LINES li_colines .READ TABLE it_content INDEX li_colines .*邮件属性ls_hd_change-objla = 'E' .ls_hd_change-objnam = 'URGENT' .ls_hd_change-dldat = sy-datum + 10 .ls_hd_change-objdes = '邮件标题' .ls_hd_change-objsns = 'O' . "私人信件* 信件的长度ls_hd_change-objlen = ( li_colines - 1 ) * 255+ STRLEN( it_content-line ).**附件CLEAR: it_packlist .it_packlist-transf_bin = 'X' .it_packlist-head_start = 1 .it_packlist-head_num = 1 .it_packlist-body_start = 1 .it_packlist-body_num = li_pdflines .it_packlist-objtp = 'PDF' .it_packlist-objnam = 'PO'.it_packlist-objdes = 'BB.PDF' ."filename .it_packlist-objlen = li_pdflines * 255 . APPEND it_packlist .* 收件人CLEAR: it_receivers .it_receivers-rcdat = sy-datum .it_receivers-rctim = sy-uzeit .it_receivers-sndpri = 1 .it_receivers-sndart = 'INT' .it_receivers-mailstatus = 'E' .it_receivers-sndex = 'X' ."快件Expressit_receivers-recesc = 'U' . "互联网it_receivers-recextnam = 'AABBCC@' . APPEND it_receivers .**发送邮件CALL FUNCTION 'SO_OBJECT_SEND'EXPORTINGobject_hd_change = ls_hd_changeobject_type = 'RAW'owner = sy-unameTABLESobjcont = it_contentreceivers = it_receiverspacking_list = it_packlistatt_cont = objbinEXCEPTIONSactive_user_not_exist = 1communication_failure = 2component_not_available = 3folder_not_exist = 4folder_no_authorization = 5forwarder_not_exist = 6note_not_exist = 7object_not_exist = 8object_not_sent = 9object_no_authorization = 10object_type_not_exist = 11operation_no_authorization = 12owner_not_exist = 13parameter_error = 14substitute_not_active = 15substitute_not_defined = 16system_failure = 17too_much_receivers = 18user_not_exist = 19originator_not_exist = 20x_error = 21OTHERS = 22. ENDFORM .。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
采购订单发送邮件:截图如下:代码如下:ZMMR099:********************************************************************* ****Program name: ZMMR099**Description : PO SEND MAIL**Date/Autohr :********************************************************************* ***** M O D I F I C A T I O N L O G********************************************************************* ***** ChangeDate Programmer Request Description** ========== ========== ========== =========================*********************************************************************** ***REPORT ZMMR099NO STANDARD PAGE HEADINGLINE-SIZE 255LINE-COUNT 255.*** Global Data declearINCLUDE ZMMR099TOP.INCLUDE ZMMR099F01.*==================================================================== ==** Selection Screen Events*==================================================================== ==**** maintain selection screen outputAT SELECTION-SCREEN OUTPUT.*** F4 value help*AT SELECTION-SCREEN ON VALUE-REQUEST for <para/sel-opt>.*** check input dataAT SELECTION-SCREEN.*AT SELECTION-SCREEN ON <f>.*AT SELECTION-SCREEN ON BLOCK <>.****CHECK ON SELECT SCREEN INPUT*==================================================================== ==** Report Events*==================================================================== ==**** initial dataINITIALIZATION.clear: ADRNR2,SUPP_NAME2 ,SUPP_NAMECO ,SUPP_STR1 , "street2 SUPP_STR2 , "street3 SUPP_STREET,SUPP_CITY ,SUPP_CN ,SUPP_CN_NAME ,SUPP_ALL ,SUPP_FRISTNAME ,SUPP_LASTNAME ,SUPP_ANRED ,SUPP_PRSNR ,TEL_NUMBER ,TEL_EXTENS ,SUPP_TEL ,ADRNR ,DELV_NAME1 ,DELV_NAME2 ,DELV_STR1 ,DELV_STR2 ,DELV_STREET ,DELV_CITY ,DELV_CN ,DELV_CN_NAME ,DELV_FRISTNAME ,DELV_LASTNAME ,DELV_ANRED ,DELV_PRSNR ,TEL_NUMBER1 ,TEL_EXTENS1 ,DELV_TEL ,PUR_TOTAL ,TAX_TOTAL ,NET_TOTAL ,DEL_PLACE ,HEAD_LINE ,REMARK ,ITEM_LINE,TDNAME .*** prepare report dataSTART-OF-SELECTION."显示清单用于显示当前所抓取的所有的清单PERFORM SHOW_LIST.*** output reportEND-OF-SELECTION.*==================================================================== ==** List Events*==================================================================== ==**** page headerTOP-OF-PAGE.*** page header after first listTOP-OF-PAGE DURING LINE-SELECTION.*** page footerEND-OF-PAGE.*** when double clickAT LINE-SELECTION.*** when click some icon (function code)*at user-command.Include的代码如下:ZMMR099TOP:*&---------------------------------------------------------------------**& 包含 ZMMR099TOP*&---------------------------------------------------------------------*TABLES: EKKO , EKPO , NAST ,TNAPR.data XSCREEN(1) type C.data GS_PO_HEAER like ZMPO_HERDER.data GS_PO_HEAER1 like ZMPO_HERDER occurs 0 with header line .data: LT_ZPO_ITEM like ZMPO_ITEM occurs 0 with header line.data: GI_RETCODE type I,ADRNR2 type T001W-ADRNR,SUPP_NAME1 like ADRC-NAME1,SUPP_NAME2 like ADRC-NAME1,******************************************LIFNR like LFA1-LIFNR,UKURS like TCURR-UKURS,******************************************SUPP_NAMECO like ADRC-NAME_CO,SUPP_STR1 like ADRC-STR_SUPPL1,SUPP_STR2 like ADRC-STR_SUPPL1,SUPP_STREET like ADRC-STREET,SUPP_CITY like ADRC-CITY1,SUPP_CN like ADRC-COUNTRY,SUPP_CN_NAME like T005T-LANDX,SUPP_ALL type STRING,"SUPP_FRISTNAME like KNVK-NAMEV,SUPP_LASTNAME like KNVK-NAME1,SUPP_ANRED like KNVK-ANRED,SUPP_PRSNR like KNVK-PRSNR,TEL_NUMBER like ADR2-TEL_NUMBER,TEL_EXTENS like ADR2-TEL_EXTENS,FAX_NUMBER like ADRC-FAX_NUMBER,SUPP_TEL like KNVK-TELF1,ADRNR type T001W-ADRNR,KTOKK like LFA1-KTOKK,DELV_NAME1 like ADRC-NAME1,DELV_NAME2 like ADRC-NAME1,DELV_CO like ADRC-NAME_CO,DELV_STR1 like ADRC-STR_SUPPL1, "street2 DELV_STR2 like ADRC-STR_SUPPL1, "street3 DELV_STREET like ADRC-STREET,DELV_CITY like ADRC-CITY1,DELV_CN like ADRC-COUNTRY,DELV_CN_NAME like T005T-LANDX,DELV_FRISTNAME like KNVK-NAMEV,DELV_LASTNAME like KNVK-NAME1,DELV_ANRED like KNVK-ANRED,DELV_PRSNR like KNVK-PRSNR,TEL_NUMBER1 like ADR2-TEL_NUMBER,TEL_EXTENS1 like ADR2-TEL_EXTENS,DELV_TEL like KNVK-TELF1,PUR_TOTAL like EKPO-NETWR,TAX_TOTAL like EKPO-NETWR,NET_TOTAL like EKPO-NETWR,COM_PLACE like ADRC-STREET,DEL_PLACE like LFA1-STRAS,HEAD_LINE like TLINE occurs 0 with header line,REMARK like TLINE-TDLINE ,ITEM_LINE like TLINE occurs 0 with header line,TDNAME like RSTXT-TDNAME,GAP type C value ' ',GAP1 type C value '-',POMENGE1 like EKPO-MENGE,POMENGE2 like EKPO-MENGE.data:AUTH_BUKRS like EKKO-BUKRS.data: ITCURR like TCURR occurs 0 with header line. data I_GDATU like EKKO-BEDAT."sy-datum.data: BEGIN OF g_itab OCCURS 0,EBELN like ekko-ebeln,EKORG LIKE EKKO-EKORG,END OF g_itab.TYPE-POOLS: slis.*TYPES: BEGIN OF wa_EKKO,* mark type c,* ebeln TYPE EKKO-ebeln,* ekorg TYPE EKKO-ekorg,* ekgrp type ekko-ekgrp ,* bedat type ekko-bedat ,* lifnr type ekko-lifnr ,* BSART type EKKO-BSART ,* END OF wa_EKKO.*data: BEGIN OF it_EKKO OCCURS 0,mark type c,ebeln TYPE EKKO-ebeln,ekorg TYPE EKKO-ekorg,ekgrp type ekko-ekgrp ,bedat type ekko-bedat ,lifnr type ekko-lifnr ,BSART type EKKO-BSART ,END OF it_EKKO."DATA: it_EKKO TYPE TABLE OF wa_EKKO ,data:l_pos TYPE i VALUE 1.DATA: gt_fieldcat TYPE slis_t_fieldcat_alv,wa_fieldcat TYPE slis_fieldcat_alv.data gt_events TYPE slis_t_event.data: P_EBELN like ekko-ebeln.data: LS_JOB_INFO1 type SSFCRESCL.data :job_output_options TYPE ssfcresop.data: OBJBIN like SOLISTI1 occurs 10 with header line,DOCDATA like SODOCCHGI1,OBJTXT like SOLISTI1 occurs 10 with header line,OBJPACK like SOPCKLSTI1 occurs 1 with header line,RECLIST like SOMLRECI1 occurs 1 with header line,OBJHEAD like SOLISTI1 occurs 1 with header line.data: i_pdf_tab LIKE TABLE OF tline WITH HEADER LINE.data: g_filesize TYPE i.data: TAB_LINES type I.data: P_XSCRN TYPE c VALUE 'X'.SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.SELECT-OPTIONS: s_ebeln FOR ekko-ebeln ,s_ekorg FOR ekko-ekorg ,s_ekgrp FOR ekko-ekgrp ,s_bedat FOR ekko-bedat ,s_lifnr FOR ekko-lifnr ,S_BSART FOR EKKO-BSART ."parameters P_XSCRN as checkbox default 'X'.SELECTION-SCREEN END OF BLOCK b1.Include ZMMR099F01代码如下:*&---------------------------------------------------------------------**& 包含 ZMMR099F01*&---------------------------------------------------------------------*FORM entry_neu USING return_code us_screen.DATA: li_retcode TYPE sy-subrc.xscreen = us_screen.PERFORM processing USING us_screenCHANGING li_retcode.IF li_retcode NE 0.return_code = 1.ELSE.return_code = 0.ENDIF.ENDFORM. "entry_neu*&---------------------------------------------------------------------**& Form processing*&---------------------------------------------------------------------** text*----------------------------------------------------------------------** -->PROC_SCREEN text* -->CF_RETCODE text*----------------------------------------------------------------------*FORM processing USING proc_screenCHANGING cf_retcode.DATA: lc_fm_name TYPE rs38l_fnam.DATA: ls_control_param TYPE ssfctrlop.DATA: ls_composer_param TYPE ssfcompop.DATA: lc_formname TYPE tdsfname.* Clear variantCLEAR gs_po_heaer.* SmartForm from customizing table TNAPRlc_formname = tnapr-sform.* select print dataPERFORM get_data CHANGING cf_retcode.READ TABLE gs_po_heaer1 INDEX 1.MOVE-CORRESPONDING gs_po_heaer1 TO gs_po_heaer.* delete adjacent duplicates from gs_po_header comparing eleln.IF cf_retcode = 0.PERFORM set_print_param CHANGING ls_control_paramls_composer_paramcf_retcode.ENDIF.IF cf_retcode = 0.* determine smartform function module for invoiceCALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'EXPORTINGformname = lc_formnameIMPORTINGfm_name = lc_fm_nameEXCEPTIONSno_form = 1no_function_module = 2OTHERS = 3.IF sy-subrc <> 0.* error handlingcf_retcode = sy-subrc.PERFORM protocol_update.ENDIF.ENDIF.CLEAR ls_job_info1.CALL FUNCTION lc_fm_namecontrol_parameters = ls_control_paramoutput_options = ls_composer_paramuser_settings = spacegs_po_heaer = gs_po_heaerpur_total = pur_totaltax_total = tax_totalnet_total = net_totaldel_place = del_placeremark = remarkIMPORTINGjob_output_info = ls_job_info1TABLESit_zpo_item = lt_zpo_item[]EXCEPTIONSformatting_error = 1internal_error = 2send_error = 3user_canceled = 4OTHERS = 5.* ls_control_param-no_open = 'X'.break abap01.IF sy-subrc <> 0.* error handlingcf_retcode = sy-subrc.PERFORM protocol_update.* get SmartForm protocoll and store it in the NAST protocoll PERFORM add_smfrm_prot.ENDIF.*ls_control_param-getotf = 'X'.ls_control_param-no_dialog = 'X'.ls_control_param-langu = sy-langu.CLEAR ls_job_info1.CALL FUNCTION lc_fm_namecontrol_parameters = ls_control_paramoutput_options = ls_composer_paramuser_settings = spacegs_po_heaer = gs_po_heaerpur_total = pur_totaltax_total = tax_totalnet_total = net_totaldel_place = del_placeremark = remarkIMPORTINGjob_output_info = ls_job_info1TABLESit_zpo_item = lt_zpo_item[]EXCEPTIONSformatting_error = 1internal_error = 2send_error = 3user_canceled = 4OTHERS = 5.PERFORM savapdf.CLEAR gs_po_heaer.ENDFORM. "PROCESSING*&---------------------------------------------------------------------**& Form set_print_param*&---------------------------------------------------------------------** text*----------------------------------------------------------------------** -->CS_CONTROL_PARAM text* -->CS_COMPOSER_PARAM text* -->CF_RETCODE text*----------------------------------------------------------------------*FORM set_print_param CHANGING cs_control_param TYPE ssfctrlopcs_composer_param TYPE ssfcompopcf_retcode TYPE sy-subrc.DATA: ls_itcpo TYPE itcpo.DATA: lf_repid TYPE sy-repid.DATA: lf_device TYPE tddevice.cs_composer_param-tddest = 'LP01'.cs_composer_param-tdimmed = 'X'.IF xscreen = 'X'.cs_composer_param-tdnoprint = 'X'.ENDIF.cs_control_param-device = 'PRINTER'.* cs_control_param-device = 'MAIL'.cs_control_param-no_dialog = 'X'.cs_control_param-preview = xscreen.cs_control_param-langu = 'M'.ENDFORM. "set_print_param*&---------------------------------------------------------------------**& Form protocol_update*&---------------------------------------------------------------------** text*----------------------------------------------------------------------*FORM protocol_update .CHECK xscreen = space.CALL FUNCTION 'NAST_PROTOCOL_UPDATE'EXPORTINGmsg_arbgb = syst-msgidmsg_nr = syst-msgnomsg_ty = syst-msgtymsg_v1 = syst-msgv1msg_v2 = syst-msgv2msg_v3 = syst-msgv3msg_v4 = syst-msgv4EXCEPTIONSOTHERS = 1.ENDFORM. " protocol_update*&---------------------------------------------------------------------**& Form add_smfrm_prot*&---------------------------------------------------------------------** text*----------------------------------------------------------------------*FORM add_smfrm_prot .DATA: lt_errortab TYPE tsferror.FIELD-SYMBOLS: <fs_errortab> TYPE LINE OF tsferror.* get smart form protocollCALL FUNCTION 'SSF_READ_ERRORS'IMPORTINGerrortab = lt_errortab.* add smartform protocoll to nast protocollLOOP AT lt_errortab ASSIGNING <fs_errortab>.CALL FUNCTION 'NAST_PROTOCOL_UPDATE'EXPORTINGmsg_arbgb = <fs_errortab>-msgidmsg_nr = <fs_errortab>-msgnomsg_ty = <fs_errortab>-msgtymsg_v1 = <fs_errortab>-msgv1msg_v2 = <fs_errortab>-msgv2msg_v3 = <fs_errortab>-msgv3msg_v4 = <fs_errortab>-msgv4EXCEPTIONSOTHERS = 1.ENDLOOP.ENDFORM. " add_smfrm_prot*&---------------------------------------------------------------------**& Form protocol_update_spool*&---------------------------------------------------------------------** text*----------------------------------------------------------------------** -->SYST_MSGNO text* -->P_LS_SPOOLID text* -->P_SPACE1 text* -->P_SPACE2 text* -->P_SPACE3 text*----------------------------------------------------------------------*FORM protocol_update_spool USING syst_msgnop_ls_spoolidp_space1p_space2p_space3.syst-msgid = 'ME'.syst-msgno = syst_msgno.syst-msgv1 = p_ls_spoolid.CONDENSE syst-msgv1.CHECK xscreen = space.CALL FUNCTION 'NAST_PROTOCOL_UPDATE'EXPORTINGmsg_arbgb = syst-msgidmsg_nr = syst-msgnomsg_ty = syst-msgtymsg_v1 = syst-msgv1msg_v2 = p_space1msg_v3 = p_space2msg_v4 = p_space3EXCEPTIONSOTHERS = 1.ENDFORM. " protocol_update_spool*&---------------------------------------------------------------------**& Form get_data*&---------------------------------------------------------------------** text*----------------------------------------------------------------------** -->CF_RETCODE text*----------------------------------------------------------------------*FORM get_data CHANGING cf_retcode.DATA lv_ebeln LIKE ekko-ebeln.DATA: cnt(2) TYPE c,persno(10) TYPE c.IF nast-objky+10 NE space.nast-objky = nast-objky+16(10).ELSE.nast-objky = nast-objky.ENDIF.lv_ebeln = nast-objky.SELECT DISTINCT ekko~bukrs ekko~lifnr ekko~ebeln ekko~bsart ekko~ae datekko~inco1 ekko~inco2 ekpo~werks ekko~waers ekko~frgzu ekko~ ztermekko~ernam ekko~bedat ekko~ekorg ekko~ekgrp ekko~wkurs"汇率INTO CORRESPONDING FIELDS OF TABLE gs_po_heaer1FROM ekkoJOIN ekpo ON ekpo~ebeln = ekko~ebelnWHERE ekko~ebeln = lv_ebeln.LOOP AT gs_po_heaer1.SELECT SINGLE lgort INTO gs_po_heaer1-lgort FROM ekpo WHERE ekpo~ ebeln = gs_po_heaer1-ebeln.SELECT SINGLE bednr INTO gs_po_heaer1-bednr FROM eban WHERE eban~ ebeln = gs_po_heaer1-ebeln.SELECT SINGLE afnam INTO gs_po_heaer1-afnam FROM eban WHERE eban~ ebeln = gs_po_heaer1-ebeln.********************************************************************* ************************************SELECT SINGLE ukurs INTO gs_po_heaer1-ukurs FROM tcurr WHERE tcu rr~kurst EQ 'M'AND fcurr EQ 'USD' "从货币AND tcurr EQ gs_po_heaer1-waers "最终货币AND tcurr~gdatu <= gs_po_heaer1-bedatAND gdatu > i_gdatu.* *******************************IF gs_po_heaer1-bukrs = 1000.gs_po_heaer1-ztitel = '香港天惠有限公司'.ELSEIF gs_po_heaer1-bukrs = 3000.gs_po_heaer1-ztitel = '东莞添威电子制品有限公司'.ENDIF.**************************************************************************************************** *************************************MODIFY gs_po_heaer1.ENDLOOP.SELECT ekpo~ebeln ekpo~ebelp ekpo~matnr ekpo~ematn ekpo~txz01ekpo~menge ekpo~meins ekpo~netpr ekko~waers ekko~bsartekpo~netwr ekpo~peinh ekpo~mwskz ekpo~infnr ekpo~werksekpo~bukrs ekpo~bprme ekpo~bpumz ekpo~bpumn ekpo~zzsub_matnr ekpo~banfn ekpo~bednr ekpo~loekz ekpo~idnlf ekpo~zzdeudate* "EKET~MENGE EKET~EINDT* ekpo~umren ekpo~umrez ekpo~lmeinINTO CORRESPONDING FIELDS OF TABLE lt_zpo_itemFROM ekpoJOIN ekko ON ekpo~ebeln = ekko~ebeln* JOIN EKET ON EKET~EBELN = EKPO~EBELN AND EKET~EBELP = EKPO~EBELP WHERE ekpo~ebeln = lv_ebeln .* AND ekpo~loekz <> 'L'.CLEAR pur_total.CLEAR tax_total.CLEAR net_total.DESCRIBE TABLE lt_zpo_item LINES sy-tmaxl.IF sy-tmaxl = 0.MESSAGE i004(zmseg).STOP.ENDIF.LOOP AT lt_zpo_item.************************添加物料版次DATA: max_aennr(12) TYPE c.SELECT MAX( aeoi~aennr ) INTO max_aennr FROM aeoi WHERE aeoi~oitx t = '修改版本' AND aeoi~objkt = lt_zpo_item-matnr.SELECT SINGLE aeoi~revlv INTO lt_zpo_item-revlv FROM aeoi WHERE aeoi~aennr = max_aennr.******************************************CLEAR lt_zpo_item-atwrt. CLEAR lt_zpo_item-atwrt2. CLEAR lt _zpo_item-atwrt3.CLEAR lt_zpo_item-ematn. CLEAR lt_zpo_item-ematn2.IF lt_zpo_item-loekz = 'L'.lt_zpo_item-menge = 0.ENDIF.IF lt_zpo_item-zzsub_matnr = ''.SELECT SINGLE atwrt INTO lt_zpo_item-atwrtFROM auspWHERE objek = lt_zpo_item-matnrAND atinn = '0000000008'AND atwrt <> ''.SELECT SINGLE atwrt INTO lt_zpo_item-atwrt2FROM auspWHERE objek = lt_zpo_item-matnrAND atinn = '0000000034'AND atwrt <> ''.CONCATENATE lt_zpo_item-atwrt lt_zpo_item-atwrt2 INTO lt_zpo_it em-ematn2.* IF sy-subrc = 0.* lt_zpo_item-ematn = lt_zpo_item-atwrt.* ENDIF.CLEAR lt_zpo_item-atwrt.SELECT SINGLE atwrt INTO lt_zpo_item-atwrt3FROM auspWHERE objek = lt_zpo_item-matnrAND atinn = '0000000009'AND atwrt <> ''.IF sy-subrc = 0.CONCATENATE lt_zpo_item-atwrt3 ':' lt_zpo_item-ematn2 INTO l t_zpo_item-ematn2.ENDIF.ELSE.SELECT SINGLE atwrt INTO lt_zpo_item-atwrtFROM auspWHERE objek = lt_zpo_item-zzsub_matnrAND atinn = '0000000008'AND atwrt <> ''.SELECT SINGLE atwrt INTO lt_zpo_item-atwrt2FROM auspWHERE objek = lt_zpo_item-zzsub_matnrAND atinn = '0000000034'AND atwrt <> ''.CONCATENATE lt_zpo_item-atwrt lt_zpo_item-atwrt2 INTO lt_zpo_it em-ematn2.* IF sy-subrc = 0.* lt_zpo_item-ematn = lt_zpo_item-atwrt.* ENDIF.CLEAR lt_zpo_item-atwrt.SELECT SINGLE atwrt INTO lt_zpo_item-atwrt3FROM auspWHERE objek = lt_zpo_item-zzsub_matnrAND atinn = '0000000009'AND atwrt <> ''.IF sy-subrc = 0.CONCATENATE lt_zpo_item-atwrt3 ':' lt_zpo_item-ematn2 INTO l t_zpo_item-ematn2.ENDIF.ENDIF.SELECT SINGLE zeivr INTO lt_zpo_item-zeivrFROM maraWHERE matnr = lt_zpo_item-matnr.*when the currency is JPY,IF lt_zpo_item-waers = 'JPY'.lt_zpo_item-netpr = lt_zpo_item-netpr * 100.ENDIF.*when the currency is JPYCLEAR: pomenge1,pomenge2.SELECT b~maktx a~mfrpn a~wrkstINTO (lt_zpo_item-maktx,lt_zpo_item-mfrpn,lt_zpo_item-wrkst)FROM mara AS aJOIN makt AS b ON a~matnr = b~matnrWHERE a~matnr = lt_zpo_item-ematn.ENDSELECT.IF lt_zpo_item-peinh <> 0.lt_zpo_item-netpr = lt_zpo_item-netpr / lt_zpo_item-peinh.ENDIF.CLEAR:pomenge1,pomenge2.pomenge1 = lt_zpo_item-menge.IF frac( pomenge1 ) <> 0.lt_zpo_item-menge1 = pomenge1 .ELSE.lt_zpo_item-menge1 = trunc( pomenge1 ).ENDIF.pomenge2 = lt_zpo_item-menge * lt_zpo_item-bpumz / lt_zpo_item-bpumn.lt_zpo_item-netwr = pomenge2 * lt_zpo_item-netpr.IF frac( pomenge2 ) <> 0.lt_zpo_item-menge2 = pomenge2 .ELSE.lt_zpo_item-menge2 = trunc( pomenge2 ).ENDIF.lt_zpo_item-netpr1 = lt_zpo_item-netpr.lt_zpo_item-netwr1 = lt_zpo_item-netwr.CONDENSE lt_zpo_item-menge1.CONDENSE lt_zpo_item-menge2.CONDENSE lt_zpo_item-netpr1.CONDENSE lt_zpo_item-netwr1.CLEAR lt_zpo_item-item_tax.IF lt_zpo_item-mwskz = 'J0' OR lt_zpo_item-mwskz = 'Y0' OR lt_zpo _item-mwskz = 'Z0'.lt_zpo_item-item_tax = lt_zpo_item-netwr * 0.ENDIF.IF lt_zpo_item-mwskz = 'J1' OR lt_zpo_item-mwskz = 'Y1' OR lt_zpo _item-mwskz = 'Z1'.lt_zpo_item-tax_code = '17%'.lt_zpo_item-item_tax = lt_zpo_item-netwr * 17 / 100.ENDIF.IF lt_zpo_item-mwskz = 'J2' OR lt_zpo_item-mwskz = 'Z2'.lt_zpo_item-tax_code = '11%'.lt_zpo_item-item_tax = lt_zpo_item-netwr * 11 / 100.ENDIF.IF lt_zpo_item-mwskz = 'J3' OR lt_zpo_item-mwskz = 'Z3'.lt_zpo_item-tax_code = '7%'.lt_zpo_item-item_tax = lt_zpo_item-netwr * 7 / 100.ENDIF.IF lt_zpo_item-mwskz = 'J4' OR lt_zpo_item-mwskz = 'Z4'.lt_zpo_item-tax_code = '6%'.lt_zpo_item-item_tax = lt_zpo_item-netwr * 6 / 100.ENDIF.IF lt_zpo_item-mwskz = 'J5'.lt_zpo_item-tax_code = '4%'.lt_zpo_item-item_tax = lt_zpo_item-netwr * 4 / 100.ENDIF.IF lt_zpo_item-mwskz = 'Z5'.lt_zpo_item-tax_code = '3%'.lt_zpo_item-item_tax = lt_zpo_item-netwr * 3 / 100.ENDIF.lt_zpo_item-item_tax1 = lt_zpo_item-item_tax.lt_zpo_item-item_total = lt_zpo_item-item_tax + lt_zpo_item-netwr.CONDENSE lt_zpo_item-item_tax1.tax_total = tax_total + lt_zpo_item-item_tax.net_total = net_total + lt_zpo_item-netwr.pur_total = net_total + tax_total.*get po info textCLEAR tdname.* CONCATENATE LT_ZPO_ITEM-INFNR LT_ZPO_ITEM-BUKRS '0'* INTO TDNAME. " LT_ZPO_ITEM-WERKSCONCATENATE lt_zpo_item-ebeln lt_zpo_item-ebelpINTO tdname. " LT_ZPO_ITEM-WERKSCALL FUNCTION 'READ_TEXT'EXPORTINGclient = sy-mandtid = 'F01'language = '1'name = tdnameobject = 'EKPO'* ARCHIVE_HANDLE = 0* LOCAL_CAT = ' '* IMPORTING* HEADER =TABLESlines = item_lineEXCEPTIONSid = 1language = 2name = 3not_found = 4object = 5reference_check = 6wrong_access_to_archive = 7OTHERS = 8 .IF sy-subrc = 0.LOOP AT item_line.CONCATENATE lt_zpo_item-itemtext item_line-tdline INTOlt_zpo_item-itemtext.ENDLOOP.CLEAR item_line.ENDIF.IF lt_zpo_item-itemtext IS NOT INITIAL.CONCATENATE 'Remark: ' lt_zpo_item-itemtext INTO lt_zpo_item-itemtext.ENDIF.SELECT SINGLE eindt INTO lt_zpo_item-eindtFROM eket WHERE ebeln = lt_zpo_item-ebelnAND ebelp = lt_zpo_item-ebelp.********************************修改再计划日期为交货日期IF lt_zpo_item-zzdeudate IS NOT INITIAL.lt_zpo_item-eindt = lt_zpo_item-zzdeudate.ENDIF.PERFORM delete_zero USING lt_zpo_item-ebelp.MODIFY lt_zpo_item.CLEAR lt_zpo_item.ENDLOOP.LOOP AT gs_po_heaer1.*&gain header texttdname = gs_po_heaer1-ebeln.CALL FUNCTION 'READ_TEXT'EXPORTING* CLIENT = SY-MANDTid = 'F01'language = sy-languname = tdnameobject = 'EKKO'* ARCHIVE_HANDLE = 0* LOCAL_CAT = ' '* IMPORTING* HEADER =* OLD_LINE_COUNTER =TABLESlines = item_line EXCEPTIONSid = 1language = 2name = 3not_found = 4object = 5reference_check = 6wrong_access_to_archive = 7OTHERS = 8.IF sy-subrc = 0.READ TABLE item_line INDEX 1.MOVE item_line-tdline TO gs_po_heaer1-mrpno.ENDIF.SELECT SINGLE eknam smtp_addrINTO (gs_po_heaer1-eknam,gs_po_heaer1-smtp_addr2)FROM t024WHERE ekgrp = gs_po_heaer1-ekgrp.SELECT adrnrINTO adrnr2FROM t001wWHERE werks = gs_po_heaer1-werks.IF sy-subrc = 0.SELECT streetINTO gs_po_heaer1-addressFROM adrcWHERE addrnumber = adrnr2.ENDSELECT.ENDIF.ENDSELECT.SELECT adrnrINTO adrnrFROM lfa1WHERE lifnr = gs_po_heaer1-lifnr.ENDSELECT.SELECT name1 name2 city1 name_co str_suppl1 str_suppl2 country street tel_number fax_numberINTO (supp_name1,supp_name2,supp_city,supp_nameco,supp_str1, supp_str2,supp_cn,supp_street,tel_number,fax_number) FROM adrcWHERE addrnumber = adrnr.ENDSELECT.SELECT landxINTO supp_cn_nameFROM t005tWHERE spras = 'E'AND land1 = supp_cn.ENDSELECT.CONDENSE supp_name1.CONDENSE supp_name2.gs_po_heaer1-supp_co = supp_nameco.gs_po_heaer1-supp_strone = supp_str1.gs_po_heaer1-supp_strtwo = supp_str2.gs_po_heaer1-supp_tel = tel_number.gs_po_heaer1-supp_fax = fax_number.gs_po_heaer1-address = supp_street.CONCATENATE supp_street supp_city supp_cn_nameINTO gs_po_heaer1-supp_cn SEPARATED BY gap .CONCATENATE supp_name1 supp_name2 INTO gs_po_heaer1-supp_name SEPARATED BY gap.SELECT SINGLE namev name1 anred prsnrINTO (supp_fristname,supp_lastname,supp_anred,supp_prsnr)FROM knvkWHERE lifnr = gs_po_heaer1-lifnr.CONCATENATE supp_lastname supp_fristname INTO gs_po_heaer1-supp_c ontact.SELECT SINGLE koinh INTO gs_po_heaer1-koinh FROM lfbk WHERE lifnr = gs_po_heaer1-lifnr.SELECT SINGLE smtp_addr INTO gs_po_heaer1-smtp_addr1FROM adr6 WHERE addrnumber = adrnr.SELECT SINGLE text1INTO gs_po_heaer1-text1FROM t052uWHERE zterm = gs_po_heaer1-zterm.IF gs_po_heaer1-inco1 = space.SELECT SINGLE inco1 inco2INTO (gs_po_heaer1-inco1,gs_po_heaer1-inco2)FROM lfm1WHERE lifnr = gs_po_heaer1-lifnrAND ekorg = gs_po_heaer1-ekorg.ELSE.SELECT SINGLE bezei INTO gs_po_heaer1-inco2FROM tinctWHERE inco1 = gs_po_heaer1-inco1AND spras = '1'.ENDIF.CLEAR persno.SELECT SINGLE persnumber INTO persnoFROM user_addrpWHERE bname = gs_po_heaer1-ernam.IF sy-subrc = 0 AND gs_po_heaer1-smtp_addr2 = space.SELECT SINGLE smtp_addr INTO gs_po_heaer1-smtp_addr2FROM adr6WHERE persnumber = persno.ENDIF.CLEAR lt_zpo_item.READ TABLE lt_zpo_item WITH KEY ebeln = gs_po_heaer1-ebeln.IF sy-subrc = 0.gs_po_heaer1-banfn = lt_zpo_item-banfn.IF lt_zpo_item-tax_code NE space.CONCATENATE '(VAT' lt_zpo_item-tax_code ')' INTO gs_po_heaer1 -taxcode.ENDIF.ENDIF.CLEAR cnt.*************采购单版本DATA:BEGIN OF tcdpos,changenr LIKE cdpos-changenr,END OF tcdpos.DATA:it_cdpos LIKE tcdpos OCCURS 0 WITH HEADER LINE.SELECT changenr INTO CORRESPONDING FIELDS OF TABLE it_cdpos FROM cdposWHERE objectid = gs_po_heaer1-ebeln AND tabname = 'EKPO' AND ( fname = 'MENGE' OR fname = 'NETWR' OR fname = 'KEY' OR fname = 'LO EKZ' )."SELECT COUNT(*) INTO cnt FROM cdpos WHERE objectid = gs_po_heae r1-ebeln AND tabname = 'EKPO' AND ( fname = 'MENGE' OR fname = 'NET WR' ).DELETE ADJACENT DUPLICATES FROM it_cdpos .cnt = lines( it_cdpos ).CONCATENATE 'Rev.' ' ' cnt INTO gs_po_heaer1-count.MODIFY gs_po_heaer1.CLEAR gs_po_heaer1.ENDLOOP.ENDFORM. "get_data*&---------------------------------------------------------------------**& Form delete_zero*&---------------------------------------------------------------------** text*----------------------------------------------------------------------** -->P_P1 text*----------------------------------------------------------------------*FORM delete_zero USING p_p1.CALL FUNCTION 'BKK_DELETE_LEADING_ZERO'CHANGINGc_field = p_p1.ENDFORM. " delete_zero*&---------------------------------------------------------------------**& Form SHOW_LIST*&---------------------------------------------------------------------** text*----------------------------------------------------------------------** --> p1 text* <-- p2 text*----------------------------------------------------------------------*FORM show_list .SELECT ebeln ekorg ekgrp bedat lifnr FROM ekkoINTO CORRESPONDING FIELDS OF TABLE it_ekkoWHERE ebeln IN s_ebeln。