版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、Smartform導(dǎo)出為 PDF 并且作為附件進(jìn)行郵件發(fā)送1 、首先獲取 Smartform 生成的功能函數(shù),CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'EXPORTINGformname= c_formnameIMPORTINGfm_name= v_fm_nameEXCEPTIONSno_formno_function_module = 2OTHERS= 3.2 、調(diào)用該函數(shù)并且在參數(shù)中設(shè)定獲取 OTF 數(shù)據(jù)st_control_parameters-no_dialog = 'X'.st_control_parameters
2、-getotf = 'X'.CALL FUNCTION v_fm_nameEXPORTINGcontrol_parameters= st_control_parametersoutput_options= st_output_optionserr_max_linewidth= 1IMPORTINGdocument_output_info = st_document_output_infojob_output_options= st_job_output_optionsTABLESpt_data= gt_dataEXCEPTIONSformatting_errorinternal
3、_errorsend_erroruser_canceledOTHERS= 5.3 、將 OTF 數(shù)據(jù)轉(zhuǎn)換成PDF 文件CALL FUNCTION 'CONVERT_OTF'EXPORTINGformat= 'PDF'IMPORTINGbin_filesize= v_bin_filesizebin_file= g_binfileTABLESotf= st_job_output_info-otfdatadoctab_archive= it_docslines= it_linesEXCEPTIONSerr_format= 2err_conv_not_possible
4、= 3 err_bad_otf= 5.OTHERSIF g_binfile IS NOT INITIAL.CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'EXPORTINGbuffer= g_binfileIMPORTINGoutput_length = v_bin_filesizeTABLESbinary_tab= gt_record.ENDIF.4、處理郵件主題,附件,收件人,發(fā)件人(默認(rèn)會(huì)是登陸用戶配置的郵箱)APPEND LINES OF GT_record TO i_objbin.*Mail Body i_objtxt-line =
5、9; 郵件正文 '.APPEND i_objtxt.DESCRIBE TABLE i_objtxt LINES v_lines_txt.wa_doc-obj_langu = SY-LANGU.wa_doc-obj_name = 'smartform'.wa_doc-expiry_dat = sy-datum + 10.wa_doc-obj_descr = ' 郵件標(biāo)題題題題題題題題題 '.wa_doc-sensitivty = 'F'.wa_doc-doc_size = v_lines_txt * 255 + v_bin_filesize
6、.* Main TextCLEAR i_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'.APPEND i_objpack.* Attachment (pdf-Attachment)CLEAR v_lines_bin.i_objpack-transf_bin = 'X'.i_objpack-head_start
7、= 1.i_objpack-head_num = 1.i_objpack-body_start = 1.i_objpack-doc_size = v_bin_filesize .i_objpack-body_num = v_lines_bin.DESCRIBE TABLE i_objbin LINES v_lines_bin.i_objpack-doc_type = 'PDF'.i_objpack-obj_name = 'smart'.i_objpack-obj_descr = 'PDF'.”這里是附件名APPEND i_objpack.CLEA
8、R i_reclist.i_reclist-rec_type = 'U'.i_reclist-receiver = 'xxx'.收件人地址APPEND i_reclist.5、調(diào)用發(fā)送郵件的函數(shù)CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'EXPORTINGdocument_data= wa_docput_in_outboxcommit_work= 'X'TABLESpacking_list= i_objpackreceivers= i_reclistobject_header= wa_
9、objhead= i_objbin= i_objtxtcontents_bincontents_txtEXCEPTIONStoo_many_receiversdocument_not_sentdocument_type_not_existoperation_no_authorization = 4parameter_errorx_errorenqueue_error= 8.OTHERS 郵件發(fā)送后可在 sost 中查看到、 6 、如果需要保存 PDF 到本地GET THE FILE NAME TO STORE*CONCATENATE 'smrt' '.pdf'
10、INTO v_name.*CREATE OBJECT v_guiobj.*CALL METHOD v_guiobj->file_save_dialogEXPORTINGdefault_extension = 'pdf'default_file_name = v_namefile_filter= v_filterCHANGINGfilename= v_namepath= v_pathfullpath= v_fullpathuser_action= v_uact.*IF v_uact = v_guiobj->action_cancel.EXIT.*ENDIF.*DOWN
11、LOAD AS FILE*MOVE v_fullpath TO v_filename.*CALL FUNCTION 'GUI_DOWNLOAD'EXPORTINGbin_filesize= v_bin_filesizefilename= v_filenamefiletype= 'BIN'TABLESdata_tab= it_linesEXCEPTIONSfile_write_errorno_batchgui_refuse_filetransfer = 3invalid_typeno_authorityunknown_errorheader_not_allowed
12、separator_not_allowed= 8filesize_not_allowedheader_too_long= 10dp_error_create= 11dp_error_send= 12dp_error_write= 13unknown_dp_error= 14access_denied= 15dp_out_of_memory= 16disk_full= 17dp_timeout= 18file_not_found= 19dataprovider_exception= 20control_flush_error= 21OTHERS= 22.完整代碼請(qǐng)見下面:*&*&
13、 Report ZTEST_MAIL3*&*& *&*&*&-REPORT ztest_mail3TYPES:BEGIN OF ty_data.TYPES:matkl TYPE mara-matkl,wgbez TYPE t023t-wgbez,matnr TYPE mara-matnr,maktx TYPE makt-maktx,ebeln TYPE ekko-ebeln,ebelp TYPE ekpo-ebelp,ekgrp TYPE ekko-ekgrp,bukrs TYPE ekko-bukrs,werks TYPE ekpo-werks,nor
14、mt TYPE mara-normt,groes TYPE mara-groes,kdatb TYPE ekko-kdatb,kdate TYPE ekko-kdate,jiaohuo(30),waibu(30),*增加物料基本單位,訂單單位DATA:gt_data TYPE TABLE OF ty_data WITH HEADER LINE.meins(3),bstme(3),*BO C2014080601增加車間和生產(chǎn)線labor_t(30),spart_t(20),*EO C2014080601增加車間和生產(chǎn)線*BO C2014082101增加物料長(zhǎng)文本 ,規(guī)格型號(hào),供應(yīng)商描述,采購(gòu)訂單
15、文beizhu(100),zeinr(22),lifnr_d(35),caigou(100),*EO C2014082101增加車間和生產(chǎn)線END OF ty_data.DATA:g_binfile TYPE xstring,gt_record TYPE TABLE OF solisti1 WITH HEADER LINE.* Internal table declarationDATA: it_otfTYPE STANDARD TABLE OF itcoo,it_docsTYPE STANDARD TABLE OF docs,it_linesTYPE STANDARD TABLE OF tl
16、ine WITH HEADER LINE.* Declaration of local variables.DATA:v_fullpathTYPE string,v_filterTYPE string,v_uactTYPE i,st_job_output_infoTYPE ssfcrescl,st_document_output_infoTYPE ssfcrespd,st_job_output_optionsTYPE ssfcresop,st_output_optionsTYPE ssfcompop,st_control_parametersTYPE ssfctrlop,v_len_inv_l
17、anguageTYPE sflangu VALUE 'E',v_e_devtypeTYPE rspoptype,v_bin_filesizeTYPE i,v_nameTYPE string,v_pathTYPE string,TYPE so_obj_len,v_filenameTYPE string,v_fm_nameTYPE rs38l_fnam.CONSTANTS c_formnameTYPE tdsfname VALUE'ZPVNP21_CN01'.DATA wa_buffer TYPE string. "To convert from 132
18、to 255DATA: i_record TYPE TABLE OF solisti1 WITH HEADER LINE,wa_doc TYPE sodocchgi1, i_reclist TYPE TABLE OF somlreci1 WITH HEADER LINE,* Objects to send mail.i_objpack TYPE TABLE OF sopcklsti1 WITH HEADER LINE,i_objtxt TYPE TABLE OF solisti1 WITH HEADER LINE,i_objbin TYPE TABLE OF solisti1 WITH HEA
19、DER LINE,* Work Area declarationswa_objhead TYPE soli_tab,* Variables declarationsv_lines_bin TYPE i.CALL FUNCTION 'SSF_GET_DEVICE_TYPE'EXPORTINGi_language= v_languagei_application = 'SAPDEFAULT'IMPORTINGe_devtype= v_e_devtype.st_output_options-tdprinter = v_e_devtype.st_control_para
20、meters-no_dialog = 'X'.st_control_parameters-getotf = 'X'.GET SMARTFORM FUNCTION MODULE NAMECALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'EXPORTINGformname= c_formnameIMPORTINGfm_name= v_fm_nameEXCEPTIONSno_formno_function_module = 2OTHERS= 3.CALL SMARTFORMCALL FUNCTION v_fm_nameEX
21、PORTINGcontrol_parameters= st_control_parametersoutput_options= st_output_optionsIMPORTINGdocument_output_info = st_document_output_infojob_output_info= st_job_output_infojob_output_options= st_job_output_optionsTABLESpt_data= gt_dataEXCEPTIONSformatting_errorinternal_errorsend_erroruser_canceledOTH
22、ERS= 5.CONVERT TO OTF TO PDFCALL FUNCTION 'CONVERT_OTF'EXPORTINGformat= 'PDF'IMPORTINGbin_file= g_binfilebin_filesize= v_bin_filesizeTABLESotf= st_job_output_info-otfdatadoctab_archive= it_docslines= it_linesEXCEPTIONSerr_max_linewidth err_format err_conv_not_possible = 3 err_bad_otf
23、= 5.OTHERSIF g_binfile IS NOT INITIAL.CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'EXPORTINGbuffer= g_binfileIMPORTINGoutput_length = v_bin_filesizeTABLESbinary_tab= gt_record.ENDIF.APPEND LINES OF GT_record TO i_objbin.*Mail Body i_objtxt-line = ' 郵件正文 '.APPEND i_objtxt.DESCRIBE TABLE i_ob
24、jtxt LINES v_lines_txt.wa_doc-obj_langu = SY-LANGU.wa_doc-obj_name = 'smartform'.wa_doc-expiry_dat = sy-datum + 10.wa_doc-obj_descr = ' 郵件標(biāo)題 '.wa_doc-sensitivty = 'F'.wa_doc-doc_size = v_lines_txt Main TextCLEAR i_objpack-transf_bin.i_objpack-head_start = 1.i_objpack-head_num
25、 = 0.i_objpack-body_start = 1.i_objpack-body_num = v_lines_txt.i_objpack-doc_type = 'RAW'.APPEND i_objpack. 255 + v_bin_filesize.* Attachment (pdf-Attachment)CLEAR v_lines_bin.i_objpack-transf_bin = 'X'.i_objpack-head_start = 1.i_objpack-head_num = 1.i_objpack-body_start = 1.DESCRIBE
26、 TABLE i_objbin LINES v_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'.APPEND i_objpack.CLEAR i_reclist.i_reclist-rec_type = 'U'.i_reclist-to_answer =
27、'X'.i_reclist-notif_read = 'X'.i_reclist-notif_del = 'X'.i_reclist-notif_ndel = 'X'.i_reclist-receiver = 'xxx'.APPEND i_reclist.CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'EXPORTINGdocument_data= wa_docput_in_outboxcommit_work= 'X'TABLESpackin
28、g_list= i_objpackobject_header= wa_objheadcontents_bin= i_objbincontents_txt= i_objtxtreceivers= i_reclistEXCEPTIONStoo_many_receiversdocument_not_sentdocument_type_not_existoperation_no_authorization = 4parameter_errorx_errorenqueue_errorOTHERS= 8.IF sy-subrc = 0.*start SAPconnect process immediatelySUBMIT rsconn01 WITH mode EQ 'INT' AND RETURN.COMMIT WORK.ENDIF.GET THE FILE
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年度高端商務(wù)區(qū)商鋪?zhàn)赓U管理協(xié)議4篇
- 專項(xiàng)工程項(xiàng)目監(jiān)管2024版委托協(xié)議版A版
- 2025年度高速公路服務(wù)區(qū)場(chǎng)標(biāo)準(zhǔn)化改造提升合同4篇
- 二零二五年度高壓直流變壓器采購(gòu)及運(yùn)輸合同3篇
- 2025年度圖書配送與圖書館管理系統(tǒng)承包合同4篇
- 2025年度拆遷安置補(bǔ)償房屋買賣合同范本(含維修)4篇
- 2024行政文員勞動(dòng)合同范本:合同違約與賠償3篇
- 2024食堂食品安全與承包合同
- 2024講座教授聘任合同模板
- 2025年度城市老舊小區(qū)拆遷安置房買賣合同規(guī)范版4篇
- 物業(yè)民法典知識(shí)培訓(xùn)課件
- 2023年初中畢業(yè)生信息技術(shù)中考知識(shí)點(diǎn)詳解
- 2024-2025學(xué)年山東省德州市高中五校高二上學(xué)期期中考試地理試題(解析版)
- 《萬方數(shù)據(jù)資源介紹》課件
- 麻風(fēng)病病情分析
- 《急診科建設(shè)與設(shè)備配置標(biāo)準(zhǔn)》
- 第一章-地震工程學(xué)概論
- TSGD7002-2023-壓力管道元件型式試驗(yàn)規(guī)則
- 2024年度家庭醫(yī)生簽約服務(wù)培訓(xùn)課件
- 建筑工地節(jié)前停工安全檢查表
- 了不起的狐貍爸爸-全文打印
評(píng)論
0/150
提交評(píng)論