版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、*&-*& Report Z7258_MAIL_EXCEL * *& * *&-*& Example of sending external email via SAPCONNECT *& * *&-*REPORT z7258_mail_excel .TABLES: ekko.PARAMETERS: p_email TYPE somlreci1-receiverDEFAULT 'sunlu'.TYPES: BEGIN OF t_ekpo,ebeln TYPE ekpo-ebeln,ebelp TYPE ekpo-ebelp
2、,aedat TYPE ekpo-aedat,matnr TYPE ekpo-matnr,END OF t_ekpo.DATA: it_ekpo TYPE STANDARD TABLE OF t_ekpo INITIAL SIZE 0,wa_ekpo TYPE t_ekpo.TYPES: BEGIN OF t_charekpo,ebeln(10 TYPE c,ebelp(5 TYPE c,aedat(8 TYPE c,matnr(18 TYPE c,END OF t_charekpo.DATA: wa_charekpo TYPE t_charekpo.DATA: it_message TYPE
3、 STANDARD TABLE OF solisti1 INITIAL SIZE 0WITH HEADER LINE.DATA: it_attach TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0WITH HEADER LINE.DATA: t_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,t_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,t_receivers LIKE somlreci1 OCCURS 0 WITH HEADER
4、LINE,t_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE,t_object_header LIKE solisti1 OCCURS 0 WITH HEADER LINE,w_cnt TYPE i,w_sent_all(1 TYPE c,w_doc_data LIKE sodocchgi1,gd_error TYPE sy-subrc,gd_reciever TYPE sy-subrc.* *START_OF_SELECTIONSTART-OF-SELECTION.* Retrieve sample data from table ekp
5、oPERFORM data_retrieval.* Populate table with detaisl to be entered into .xls filePERFORM build_xls_data_table.* *END-OF-SELECTIONEND-OF-SELECTION.* Populate message body textPERFORM populate_email_message_body.* Send file by email as .xls speadsheetPERFORM send_file_as_email_attachmentTABLES it_mes
6、sageit_attachUSING p_email'Example .xls documnet attachment''CSV''12345.CSV''1'''''CHANGING gd_errorgd_reciever.* Instructs mail send program for SAPCONNECT to send email(rsconn01 PERFORM initiate_mail_execute_program.*&-*& Form DATA_RETRIEVAL*
7、&-* Retrieve data form EKPO table and populate itab it_ekko*-*FORM data_retrieval.SELECT ebeln ebelp aedat matnrUP TO 10 ROWSFROM ekpoINTO TABLE it_ekpo.ENDFORM. " DATA_RETRIEVAL*&-*& Form BUILD_XLS_DATA_TABLE*&-* Build data table for .xls document*-*FORM build_xls_data_table.*
8、CONSTANTS: con_cret TYPE x VALUE '0D', "OK for non Unicode* con_tab TYPE x VALUE '09'. "OK for non Unicode*If you have Unicode check active in program attributes thnen you will *need to declare constants as follows*class cl_abap_char_utilities definition load.CONSTANTS:con_
9、tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab,con_cret TYPE c VALUE cl_abap_char_utilities=>cr_lf.* CONCATENATE 'EBELN' 'EBELP' 'AEDAT' 'MATNR'* INTO it_attach SEPARATED BY con_tab. CONCATENATE 'EBELN' 'EBELP' 'AEDAT' 'MATNR
10、'INTO it_attach SEPARATED BY ','.CONCATENATE con_cret it_attach INTO it_attach.APPEND it_attach.LOOP AT it_ekpo INTO wa_charekpo.* CONCATENATE wa_charekpo-ebeln wa_charekpo-ebelp* wa_charekpo-aedat wa_charekpo-matnr* INTO it_attach SEPARATED BY con_tab.CONCATENATE wa_charekpo-ebeln wa_ch
11、arekpo-ebelpwa_charekpo-aedat wa_charekpo-matnrINTO it_attach SEPARATED BY ','.CONCATENATE con_cret it_attach INTO it_attach.APPEND it_attach.ENDLOOP.ENDFORM. " BUILD_XLS_DA TA_TABLE*&-*& Form SEND_FILE_AS_EMAIL_ATTACHMENT*&-* Send email*-*FORM send_file_as_email_attachment
12、TABLES pit_messagepit_attachUSING p_emailp_mtitlep_formatp_filenamep_attdescriptionp_sender_addressp_sender_addres_typeCHANGING p_errorp_reciever.DATA: ld_error TYPE sy-subrc,ld_reciever TYPE sy-subrc,ld_mtitle LIKE sodocchgi1-obj_descr,ld_email LIKE somlreci1-receiver,ld_format TYPE so_obj_tp ,ld_a
13、ttdescription TYPE so_obj_nam ,ld_attfilename TYPE so_obj_des ,ld_sender_address LIKE soextreci1-receiver,ld_sender_address_type LIKE soextreci1-adr_typ,ld_receiver LIKE sy-subrc.ld_email = p_email.ld_mtitle = p_mtitle.ld_format = p_format.ld_attdescription = p_attdescription.ld_attfilename = p_file
14、name.ld_sender_address = p_sender_address.ld_sender_address_type = p_sender_addres_type.* Fill the document data.w_doc_data-doc_size = 1.* Populate the subject/generic message attributesw_doc_data-obj_langu = sy-langu.w_doc_data-obj_name = 'SAPRPT'.w_doc_data-obj_descr = ld_mtitle .w_doc_dat
15、a-sensitivty = 'F'.* Fill the document data and get size of attachmentCLEAR w_doc_data.READ TABLE it_attach INDEX w_cnt.w_doc_data-doc_size =( w_cnt - 1 * 255 + STRLEN( it_attach .w_doc_data-obj_langu = sy-langu.w_doc_data-obj_name = 'SAPRPT'.w_doc_data-obj_descr = ld_mtitle.w_doc_da
16、ta-sensitivty = 'F'.CLEAR t_attachment.REFRESH t_attachment.t_attachment = pit_attach.* Describe the body of the messageCLEAR t_packing_list.REFRESH t_packing_list.t_packing_list-transf_bin = space.t_packing_list-head_start = 1.t_packing_list-head_num = 0.t_packing_list-body_start = 1.DESCRI
17、BE TABLE it_message LINES t_packing_list-body_num. t_packing_list-doc_type = 'RAW'.APPEND t_packing_list.* Create attachment notificationt_packing_list-transf_bin = 'X'.t_packing_list-head_start = 1.t_packing_list-head_num = 1.t_packing_list-body_start = 1.DESCRIBE TABLE t_attachment
18、 LINES t_packing_list-body_num. t_packing_list-doc_type = ld_format.t_packing_list-obj_descr = ld_attdescription.t_packing_list-obj_name = ld_attfilename.t_packing_list-doc_size = t_packing_list-body_num * 255. APPEND t_packing_list.* Add the recipients email addressCLEAR t_receivers.REFRESH t_recei
19、vers.t_receivers-receiver = ld_email.t_receivers-rec_type = 'U'.t_receivers-com_type = 'INT'.t_receivers-notif_del = 'X'. t_receivers-notif_ndel = 'X'. APPEND t_receivers. CALL FUNCTION 'SO_DOCUMENT_SEND_API1' EXPORTING document_data = w_doc_data put_in_outbox
20、 = 'X' sender_address = ld_sender_address sender_address_type = ld_sender_address_type commit_work = 'X' IMPORTING sent_to_all = w_sent_all TABLES packing_list = t_packing_list contents_bin = t_attachment contents_txt = it_message receivers = t_receivers EXCEPTIONS too_many_receivers =1 document_not_sent =2 document_type_not_exist =3 operation_no_authorization = 4 parameter_error =5 x_error =6 enqueue_error =7 OTHERS = 8. * Populate zerror return code ld_error = sy-subrc. * Populate zreceiver return code LOOP A
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2023年國家公務員錄用考試《申論》真題(地市卷)及答案解析
- 中班 秋天課件
- 2024年1月福建省普通高中學業(yè)水平合格性考試化學試題(原卷版)
- 社區(qū)少先隊課件
- 蘇教版科學課件
- 西南林業(yè)大學《材料研究及分析方法實驗》2022-2023學年第一學期期末試卷
- 西京學院《新媒體短視頻運營實訓》2023-2024學年第一學期期末試卷
- 西京學院《前端開發(fā)技術》2021-2022學年期末試卷
- 頜下腺結石課件
- 西京學院《句法學概論》2022-2023學年期末試卷
- 2024年全國教育大會精神全文課件
- 山東省濟寧市曲阜市2024-2025學年九年級數(shù)學上學期期中試卷
- 羽毛球運動教學與訓練智慧樹知到答案2024年黑龍江農業(yè)工程職業(yè)學院
- 創(chuàng)新設計前沿智慧樹知到期末考試答案章節(jié)答案2024年浙江大學
- (完整版)工匠精神課件
- 危大工程動態(tài)判定表
- 蘇教版高中通用技術必修1:一-技術的價值課件
- 文件袋、檔案袋密封條模板
- 碎石組織供應及運輸售后服務保障方案
- HXN5型機車常見故障處理指導書
- 國家自然科學基金申請經(jīng)驗交流.ppt
評論
0/150
提交評論