Smartform导出为PDF并且作为附加资料进行邮件发送_第1页
Smartform导出为PDF并且作为附加资料进行邮件发送_第2页
Smartform导出为PDF并且作为附加资料进行邮件发送_第3页
Smartform导出为PDF并且作为附加资料进行邮件发送_第4页
Smartform导出为PDF并且作为附加资料进行邮件发送_第5页
已阅读5页,还剩16页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

.Smartform导出为PDF并且作为附件进行邮件发送1、首先获取Smartform生成的功能函数,CALLFUNCTION'SSF_FUNCTION_MODULE_NAME'谢谢阅读EXPORTINGformname =c_formnameIMPORTINGfm_name =v_fm_nameEXCEPTIONSno_form =1no_function_module=2OTHERS =3.2、调用该函数并且在参数中设定获取OTF数据st_control_parameters-no_dialog='X'.精品文档放心下载st_control_parameters-getotf='X'.精品文档放心下载EXPORTINGcontrol_parameters =st_control_parameters谢谢阅读output_options =st_output_options谢谢阅读IMPORTINGdocument_output_info=st_document_output_info感谢阅读job_output_info =st_job_output_info精品文档放心下载.job_output_options =st_job_output_options感谢阅读TABLESpt_data =gt_dataEXCEPTIONSformatting_error =1internal_error =2send_error =3user_canceled =4OTHERS =5.3、将OTF数据转换成PDF文件CALLFUNCTION'CONVERT_OTF'感谢阅读EXPORTINGformat ='PDF'IMPORTINGbin_filesize =v_bin_filesize谢谢阅读bin_file =g_binfileTABLESotf =st_job_output_info-otfdata感谢阅读* doctab_archive =it_docs谢谢阅读lines =it_linesEXCEPTIONSerr_max_linewidth =1.err_format =2err_conv_not_possible=3err_bad_otf =4OTHERS =5.IFg_binfileISNOTINITIAL.精品文档放心下载CALLFUNCTION'SCMS_XSTRING_TO_BINARY'谢谢阅读EXPORTINGbuffer =g_binfileIMPORTINGoutput_length=v_bin_filesize谢谢阅读TABLESbinary_tab =gt_record.ENDIF.4、处理邮件主题,附件,收件人,发件人(默认会是登陆用户配置的邮箱)谢谢阅读APPENDLINESOFGT_recordTOi_objbin.感谢阅读*MailBodyi_objtxt-line='邮件正文'.APPENDi_objtxt.DESCRIBETABLEi_objtxtLINESv_lines_txt.感谢阅读wa_doc-obj_langu=SY-LANGU.感谢阅读wa_doc-obj_name='smartform'.谢谢阅读wa_doc-expiry_dat=sy-datum+10.精品文档放心下载.wa_doc-obj_descr='邮件标题题题题题题题题题'.谢谢阅读wa_doc-sensitivty='F'.wa_doc-doc_size=v_lines_txt*255+v_bin_filesize.谢谢阅读*MainTextCLEARi_objpack-transf_bin.谢谢阅读i_objpack-head_start=1.i_objpack-head_num=0.i_objpack-body_start=1.i_objpack-body_num=v_lines_txt.感谢阅读i_objpack-doc_type='RAW'.精品文档放心下载APPENDi_objpack.Attachment(pdf-Attachment)CLEARv_lines_bin.i_objpack-transf_bin='X'.i_objpack-head_start=1.i_objpack-head_num=1.i_objpack-body_start=1.感谢阅读DESCRIBETABLEi_objbinLINESv_lines_bin.i_objpack-doc_size=v_bin_filesize.i_objpack-body_num=v_lines_bin.感谢阅读.i_objpack-doc_type='PDF'.精品文档放心下载i_objpack-obj_name='smart'.谢谢阅读i_objpack-obj_descr='PDF'.”这里是附件名谢谢阅读APPENDi_objpack.CLEARi_reclist.i_reclist-rec_type='U'.i_reclist-receiver='xxx@163.com'.“收件人地址APPENDi_reclist.精品文档放心下载5、调用发送邮件的函数CALLFUNCTION'SO_NEW_DOCUMENT_ATT_SEND_API1'EXPORTING谢谢阅读*

document_dataput_in_outboxcommit_workTABLESpacking_listobject_headercontents_bincontents_txtreceiversEXCEPTIONS

=wa_doc=''='X'=i_objpack=wa_objhead=i_objbin=i_objtxt=i_reclist.too_many_receivers=1document_not_sent=2document_type_not_exist=3operation_no_authorization=4parameter_error=5x_error=6enqueue_error=7OTHERS=8.邮件发送后可在sost中查看到、6、如果需要保存PDF到本地*........................GETTHEFILENAMETOSTORE....................*感谢阅读EXPORTINGdefault_extension='pdf'default_file_name=v_name精品文档放心下载*file_filter=v_filter*CHANGING*filename=v_name*path=v_path*fullpath=v_fullpath.* user_action =v_uact.*IFv_uact=v_guiobj->action_cancel.谢谢阅读EXIT.*ENDIF.**..................................DOWNLOADASFILE....................*谢谢阅读*MOVEv_fullpathTOv_filename.谢谢阅读*CALLFUNCTION'GUI_DOWNLOAD'谢谢阅读EXPORTING*bin_filesize=v_bin_filesize*filename=v_filename*filetype='BIN'*TABLES*data_tab=it_lines*EXCEPTIONS*file_write_error=1*no_batch=2gui_refuse_filetransfer=3精品文档放心下载*invalid_type=4*no_authority=5*unknown_error=6*header_not_allowed=7.*separator_not_allowed=8*filesize_not_allowed=9*header_too_long=10*dp_error_create=11*dp_error_send=12*dp_error_write=13*unknown_dp_error=14*access_denied=15*dp_out_of_memory=16*disk_full=17*dp_timeout=18*file_not_found=19dataprovider_exception=20谢谢阅读*control_flush_error=21*OTHERS=22.完整代码请见下面:*&---------------------------------------------------------------------*谢谢阅读*&Report ZTEST_MAIL3**&.**&---------------------------------------------------------------------*精品文档放心下载*&**&**&---------------------------------------------------------------------*精品文档放心下载REPORT ztest_mail3TYPES:BEGINOFty_data.TYPES:matklTYPEmara-matkl,wgbezTYPEt023t-wgbez,matnrTYPEmara-matnr,maktxTYPEmakt-maktx,ebelnTYPEekko-ebeln,ebelpTYPEekpo-ebelp,ekgrpTYPEekko-ekgrp,bukrsTYPEekko-bukrs,werksTYPEekpo-werks,lifnrTYPEekko-lifnr,netprTYPEekpo-netpr,

..normtTYPEmara-normt,groesTYPEmara-groes,kdatbTYPEekko-kdatb,kdateTYPEekko-kdate,jiaohuo(30),waibu(30),*增加物料基本单位,订单单位meins(3),bstme(3),*BOC2014080601增加车间和生产线labor_t(30),spart_t(20),*EOC2014080601增加车间和生产线*BOC2014082101增加物料长文本,规格型号,供应商描述,采购订单文感谢阅读beizhu(100),zeinr(22),lifnr_d(35),caigou(100),*EOC2014082101增加车间和生产线ENDOFty_data.DATA:gt_dataTYPETABLEOFty_dataWITHHEADERLINE.谢谢阅读.DATA:g_binfileTYPExstring,精品文档放心下载gt_recordTYPE TABLEOFsolisti1WITHHEADERLINE.精品文档放心下载*Internaltabledeclaration感谢阅读DATA:it_otf TYPESTANDARDTABLEOFitcoo,精品文档放心下载it_docs TYPESTANDARDTABLEOFdocs,谢谢阅读it_lines TYPESTANDARDTABLEOFtlineWITHHEADERLINE.谢谢阅读Declarationoflocalvariables.DATA:感谢阅读st_job_output_info TYPEssfcrescl,感谢阅读st_document_output_info TYPEssfcrespd,感谢阅读st_job_output_options TYPEssfcresop,感谢阅读st_output_options TYPEssfcompop,精品文档放心下载st_control_parameters TYPEssfctrlop,精品文档放心下载v_len_in TYPEso_obj_len,v_language TYPEsflanguVALUE'E',精品文档放心下载v_e_devtype TYPErspoptype,感谢阅读v_bin_filesize TYPEi,v_name TYPEstring,v_path TYPEstring,v_fullpath TYPEstring,v_filter TYPEstring,v_uact TYPEi,.v_guiobjv_filenamev_fm_nameCONSTANTSc_formname'ZPVNP21_CN01'.

TYPEREFTOcl_gui_frontend_services,感谢阅读TYPEstring,TYPErs38l_fnam.TYPEtdsfnameVALUEDATAwa_bufferTYPEstring."Toconvertfrom132to255精品文档放心下载DATA:i_recordTYPETABLEOFsolisti1WITHHEADERLINE,wa_docTYPEsodocchgi1,精品文档放心下载i_reclistTYPETABLEOFsomlreci1WITHHEADERLINE,感谢阅读*Objectstosendmail.i_objpackTYPETABLEOFsopcklsti1WITHHEADERLINE,i_objtxtTYPETABLEOFsolisti1WITHHEADERLINE,i_objbinTYPETABLEOFsolisti1WITHHEADERLINE,精品文档放心下载*WorkAreadeclarationswa_objheadTYPEsoli_tab,Variablesdeclarationsv_len_inTYPEsood-objlen,v_lines_txtTYPEi,精品文档放心下载.v_lines_binTYPEi.CALLFUNCTION'SSF_GET_DEVICE_TYPE'谢谢阅读EXPORTINGi_language =v_languagei_application='SAPDEFAULT'感谢阅读IMPORTINGe_devtype =v_e_devtype.st_output_options-tdprinter=v_e_devtype.感谢阅读st_control_parameters-no_dialog='X'.精品文档放心下载st_control_parameters-getotf='X'.精品文档放心下载*.................GETSMARTFORMFUNCTIONMODULENAME.................*精品文档放心下载CALLFUNCTION'SSF_FUNCTION_MODULE_NAME'精品文档放心下载EXPORTINGformname =c_formnameIMPORTINGfm_name =v_fm_nameEXCEPTIONSno_form =1no_function_module=2OTHERS =3.*...........................CALLSMARTFORM............................*谢谢阅读CALLFUNCTIONv_fm_name.EXPORTINGcontrol_parameters =st_control_parameters精品文档放心下载output_options =st_output_options精品文档放心下载IMPORTINGdocument_output_info=st_document_output_info感谢阅读job_output_info =st_job_output_info谢谢阅读job_output_options =st_job_output_options谢谢阅读TABLESpt_data =gt_dataEXCEPTIONSformatting_error =1internal_error =2send_error =3user_canceled =4OTHERS =5.*.........................CONVERTTOOTFTOPDF.......................*感谢阅读CALLFUNCTION'CONVERT_OTF'谢谢阅读EXPORTINGformat ='PDF'IMPORTINGbin_filesize =v_bin_filesize谢谢阅读bin_file =g_binfile.TABLESotf =st_job_output_info-otfdata感谢阅读* doctab_archive =it_docs感谢阅读lines =it_linesEXCEPTIONSerr_max_linewidth =1err_format =2err_conv_not_possible=3err_bad_otf =4OTHERS =5.IFg_binfileISNOTINITIAL.谢谢阅读CALLFUNCTION'SCMS_XSTRING_TO_BINARY'感谢阅读EXPORTINGbuffer =g_binfileIMPORTINGoutput_length=v_bin_filesize谢谢阅读TABLESbinary_tab =gt_record.ENDIF.APPENDLINESOFGT_recordTOi_objbin.精品文档放心下载*i_objbin[]=GT_record[].谢谢阅读.*MailBodyi_objtxt-line='邮件正文'.APPENDi_objtxt.DESCRIBETABLEi_objtxtLINESv_lines_txt.精品文档放心下载wa_doc-obj_langu=SY-LANGU.感谢阅读wa_doc-obj_name='smartform'.感谢阅读wa_doc-expiry_dat=sy-datum+10.谢谢阅读wa_doc-obj_descr='邮件标题'.谢谢阅读wa_doc-sensitivty='F'.wa_doc-doc_size=v_lines_txt*255+v_bin_filesize.谢谢阅读*MainTextCLEARi_objpack-transf_bin.精品文档放心下载i_objpack-head_start=1.i_objpack-head_num=0.i_objpack-body_start=1.i_objpack-body_num=v_lines_txt.谢谢阅读i_objpack-doc_type='RAW'.感谢阅读APPENDi_objpack..Attachment(pdf-Attachment)CLEARv_lines_bin.i_objpack-transf_bin='X'.i_objpack-head_start=1.i_objpack-head_num=1.i_objpack-body_start=1.精品文档放心下载DESCRIBETABLEi_objbinLINESv_lines_bin.i_objpack-doc_size=v_bin_filesize.i_objpack-body_num=v_lines_bin.i_objpack-doc_type='PDF'.i_objpack-obj_name='smart'.i_objpack-obj_descr='PDF'.精品文档放心下载APPENDi_objpack.CLEARi_reclist.i_reclist-rec_type='U'.i_reclist-to_answer='X'.精品文档放心下载i_reclist-notif_read='X'.精品文档放心下载i_reclist-notif_del='X'.谢谢阅读i_reclist-notif_ndel='X'.谢谢阅读i_reclist-receiver='xxx@163.com'.感谢阅读APPENDi_reclist..CALLFUNCTION'SO_NEW_DOCUMENT_ATT_SEND_API1'感谢阅读EXPORTINGdocument_data =wa_docput_in_outbox =''commit_work ='X'TABLESpacking_list =i_objpack* object_header =wa_objhead精品文档放心下载contents_bin =i_objbincontents_txt =i_objtxtreceivers =i_reclistEXCEPTIONStoo_many_receivers =1document_not_sent =2document_type_not_exist =3精品文档放心下载operation_no_authorization=4精品文档放心下载parameter_error =5x_error =6enqueue_error =7OTHERS =8.IFsy-subrc=0..*startSAPconnectprocessimmediately感谢阅读SUBMITrsconn01WITHmodeEQ'INT'ANDRETURN.精品文档放心下载COMMITWORK.ENDIF.*........................GETTHEFILENAMETOSTORE............

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论