已阅读5页,还剩6页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
*&-*& Report YHCNCALC0_MAIL*&*&-*&*&*&-*report yhcncalc0_mail.parameter: jobcount like tbtcm-jobcount, jobname like tbtcm-jobname, p_email1 like somlreci1-receiver, p_sender like somlreci1-receiver, p_delspl as checkbox.*DATA DECLARATIONdata: gd_recsize type i.* Spool IDstypes: begin of t_tbtcp. include structure tbtcp.types: end of t_tbtcp.data: it_tbtcp type standard table of t_tbtcp initial size 0, wa_tbtcp type t_tbtcp.* Job Runtime Parametersdata: gd_eventid like tbtcm-eventid, gd_eventparm like tbtcm-eventparm, gd_external_program_active like tbtcm-xpgactive,* gd_jobcount LIKE tbtcm-jobcount,* gd_jobname LIKE tbtcm-jobname, gd_stepcount like tbtcm-stepcount, gd_error type sy-subrc, gd_reciever type sy-subrc.data: w_recsize type i.data: gd_subject like sodocchgi1-obj_descr, it_mess_bod like solisti1 occurs 0 with header line, it_mess_att like solisti1 occurs 0 with header line, gd_sender_type like soextreci1-adr_typ, gd_attachment_desc type so_obj_nam, gd_attachment_name type so_obj_des.* Spool to PDF conversionsdata: gd_spool_nr like tsp01-rqident, gd_destination like rlgrap-filename, gd_bytecount like tst01-dsize, gd_buffer type string.* Binary store for PDFdata: begin of it_pdf_output occurs 0. include structure tline.data: end of it_pdf_output.constants: c_dev like sy-sysid value DEV, c_no(1) type c value , c_device(4) type c value LOCL.*START-OF-SELECTION.start-of-selection.* Write statement to represent report output. Spool request is created* if write statement is executed in background. This could also be an* ALV grid which would be converted to PDF without any extra effort* WRITE Hello World. new-page. commit work. new-page print off. if sy-batch eq X.* PERFORM get_job_details. perform obtain_spool_id.* Alternative way could be to submit another program and store spool* id into memory, will be stored in sy-spono.*submit ZSPOOLTOPDF2* to sap-spool* spool parameters %_print* archive parameters %_print* without spool dynpro* and return.* Get spool id from program called above* IMPORT w_spool_nr FROM MEMORY ID SPOOLTOPDF. perform convert_spool_to_pdf. perform process_email. if p_delspl eq X. perform delete_spool. endif. if sy-sysid = c_dev. wait up to 5 seconds. submit rsconn01 with mode = INT with output = X and return. endif. else. skip. write:/ Program must be executed in background in-order for spool, request to be created. endif.*-* FORM obtain_spool_id *-*form obtain_spool_id. check not ( jobname is initial ). check not ( jobcount is initial ). select * from tbtcp into table it_tbtcp where jobname = jobname and jobcount = jobcount* AND stepcount = gd_stepcount and listident 0000000000 order by jobname jobcount stepcount. read table it_tbtcp into wa_tbtcp index 1. if sy-subrc = 0. message s004(zdd) with gd_spool_nr. gd_spool_nr = wa_tbtcp-listident. message s004(zdd) with gd_spool_nr. else. message s005(zdd). endif.endform.*-* FORM get_job_details *-*FORM get_job_details.* Get current job details* CALL FUNCTION GET_JOB_RUNTIME_INFO* IMPORTING* eventid = gd_eventid* eventparm = gd_eventparm* external_program_active = gd_external_program_active* jobcount = jobcount* jobname = jobname* stepcount = gd_stepcount* EXCEPTIONS* no_runtime_info = 1* OTHERS = 2.*ENDFORM.*-* FORM convert_spool_to_pdf *-*form convert_spool_to_pdf. call function CONVERT_ABAPSPOOLJOB_2_PDF exporting src_spoolid = gd_spool_nr no_dialog = c_no dst_device = c_device importing pdf_bytecount = gd_bytecount tables pdf = it_pdf_output exceptions err_no_abap_spooljob = 1 err_no_spooljob = 2 err_no_permission = 3 err_conv_not_possible = 4 err_bad_destdevice = 5 user_cancelled = 6 err_spoolerror = 7 err_temseerror = 8 err_btcjob_open_failed = 9 err_btcjob_submit_failed = 10 err_btcjob_close_failed = 11 others = 12. check sy-subrc = 0.* Transfer the 132-long strings to 255-long strings loop at it_pdf_output. translate it_pdf_output using . concatenate gd_buffer it_pdf_output into gd_buffer. endloop. translate gd_buffer using . do. it_mess_att = gd_buffer. append it_mess_att. shift gd_buffer left by 255 places. if gd_buffer is initial. exit. endif. enddo.endform.*-* FORM process_email *-*form process_email. describe table it_mess_att lines gd_recsize. check gd_recsize 0. perform send_email using p_email1.* perform send_email using p_email2.endform.*-* FORM send_email *-* - p_email *-*form send_email using p_email. check not ( p_email is initial ). refresh it_mess_bod.* Default subject matter gd_subject = Subject. gd_attachment_desc = 工资计算日志.* CONCATENATE attach_name INTO gd_attachment_name. it_mess_bod = 您好;. append it_mess_bod. clear it_mess_bod . append it_mess_bod. concatenate 附件内容是您在 sy-datum(4) 年 sy-datum+4(2) 月 sy-datum+6(2) 日 提交的工资计算作业执行结果日志,请查收。 into it_mess_bod . append it_mess_bod. clear it_mess_bod . append it_mess_bod. it_mess_bod = 谢谢. append it_mess_bod.* If no sender specified - default blank if p_sender eq space. gd_sender_type = space. else. gd_sender_type = FAX. endif.* Send file by email as .xls speadsheet perform send_file_as_email_attachment tables it_mess_bod it_mess_att using p_email 工资计算结果日志 PDF gd_attachment_name gd_attachment_desc p_sender gd_sender_type changing gd_error gd_reciever.endform.*-* FORM delete_spool *-*form delete_spool. data: ld_spool_nr type tsp01_sp0r-rqid_char. ld_spool_nr = gd_spool_nr. check p_delspl c_no. call function RSPO_R_RDELETE_SPOOLREQ exporting spoolid = ld_spool_nr.endform.*&-*& Form SEND_FILE_AS_EMAIL_ATTACHMENT*&-* Send email*-*form send_file_as_email_attachment tables it_message it_attach using p_email p_mtitle p_format p_filename p_attdescription p_sender_address p_sender_addres_type changing p_error p_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_attdescription 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.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 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. ld_email = p_email. ld_mtitle = p_mtitle. ld_format = p_format. ld_attdescription = p_attdescription. ld_attfilename = p_filename. 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 attributes w_doc_data-obj_langu = sy-langu. w_doc_data-obj_name = SAPRPT. w_doc_data-obj_descr = ld_mtitle . w_doc_data-sensitivty = F.* Fill the document data and get size of attachment clear 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_data-sensitivty = F. clear t_attachment. refresh t_attachment. t_attachment = it_attach.* Describe the body of the message clear 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. describe table it_message lines t_packing_list-body_num. t_packing_list-doc_type = RAW. append t_packing_list.* Create attachment notification t_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 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 address clear t_receivers. refre
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
评论
0/150
提交评论