Sie sind auf Seite 1von 4

form BACKGRND_SEND_EMAIL data: l_string l_size la_org_price(16) la_ovrd_price(16) la_variation(16) lt_binary la_final

using type type type type TYPE type type

p_t_final like lt_price. string, so_obj_len, c, c, c, solix_tab, TY_PRICE.

clear: l_string. concatenate sy-title c_crlf c_crlf into l_string. *** Columns concatenate l_string 'Sales Document' 'Sales District' 'Billing Document' 'Billing item' 'Original Price' 'Override Price' 'Variation' 'COR Number' * 'Contract#' into l_string.

c_tab c_tab c_tab c_tab c_tab c_tab c_tab c_crlf c_crlf c_crlf c_crlf

*** Data rows loop at p_t_final into la_final. clear: la_org_price, la_ovrd_price. write la_final-L_ORGINAL_PRICE to la_org_price. write la_final-L_OVERRIDE_PRICE to la_ovrd_price. write la_final-L_VARIATION to la_variation. concatenate l_string la_final-AUBEL c_tab la_final-BZIRK c_tab la_final-VBELN c_tab la_final-POSNR c_tab la_org_price c_tab la_ovrd_price c_tab la_variation c_tab la_final-ZZCORDOC c_crlf into l_string. endloop.

*** convert the text string into UTF-16LE binary data including *** byte-order-mark. Mircosoft Excel prefers these settings *** all this is done by new class cl_bcs_convert try. cl_bcs_convert=>string_to_solix( exporting iv_string = l_string iv_codepage = '4103' "suitable for MS Excel, leave empty iv_add_bom = 'X' "for other doc types importing et_solix = lt_binary ev_size = l_size ). catch cx_bcs. * message e445(so). endtry. *** Using BCS send email perform send_mail using lt_binary l_size. endform. " BACKGRND_SEND_EMAIL

*&---------------------------------------------------------------------* *& Form SEND_MAIL *&---------------------------------------------------------------------* form SEND_MAIL using p_lt_binary type solix_tab p_l_size type so_obj_len. data: l_body_text type bcsy_text, l_sent_to_all type os_boolean, l_email type AD_SMTPADR. data: begin of la_emailid, ZZ_PROGRAM type ZZ_PARAM type TYPE type NUMB type SIGN type OPTI type LOW type HIGH type ZZ_PGMDATE type ZZ_PGMTIME type end of la_emailid. data: lt_emailids

ztpgm_params-zz_program, ztpgm_params-zz_param, ztpgm_params-type, ztpgm_params-numb, ztpgm_params-sign, ztpgm_params-opti, ztpgm_params-low, ztpgm_params-high, ztpgm_params-zz_pgmdate, ztpgm_params-zz_pgmtime,

like table of la_emailid.

data: lo_send_request type ref to cl_bcs, lo_document type ref to cl_document_bcs,

lo_recipient

TYPE REF TO cl_cam_address_bcs.

try. lo_send_request = cl_bcs=>create_persistent( ). append append append append append text-006 space text-007 space space to to to to to l_body_text. l_body_text. l_body_text. l_body_text. l_body_text. = cl_document_bcs=>create_document( 'RAW' l_body_text 'Manual Price Change Report' ).

lo_document i_type = i_text = i_subject =

lo_document->add_attachment( i_attachment_type = 'xls' i_attachment_subject = text-009 i_attachment_size = p_l_size i_att_content_hex = p_lt_binary ). lo_send_request->set_document( lo_document ). *** PGMTIME from ztpgm_params into table lt_emailids where zz_program = text-010 and ZZ_PARAM = text-011 and type = 'P' and sign = 'I'. if sy-subrc <> 0. clear lt_emailids. endif. * loop at lt_emailids into la_emailid. free lo_recipient. clear: l_email. l_email = la_emailid-low. lo_recipient = cl_cam_address_bcs=>create_internet_address( l_email lo_send_request->add_recipient( lo_recipient ). endloop. l_sent_to_all = lo_send_request->send( i_with_error_screen = 'X' ). Select email ids from ztpgm_params select ZZ_PROGRAM ZZ_PARAM TYPE NUMB SIGN OPTI LOW HIGH ZZ_PGMDATE ZZ_

). *

commit work. if l_sent_to_all is not initial. endif. catch cx_bcs. endtry. endform.

" SEND_MAIL

Das könnte Ihnen auch gefallen