Function module that will take any internal table as input, convert in to XLS format
and send out emails with the attachment.
Add the appropriate import parameters.
Source Code
====================================================
function zinttab_excl_email.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(SENDER) TYPE AD_SMTPADR
*" REFERENCE(SUBJECT) TYPE SO_OBJ_DES
*" TABLES
*" RECEPIENTS TYPE BCSY_SMTPA
*" RETURN TYPE TABLE_OF_STRINGS OPTIONAL
*" DATA_TO_SEND
*" EMAIL_BODY TYPE BCSY_TEXT
*"----------------------------------------------------------------------
*Function module that will take any internal table as input, convert in to XLS format
*and send out emails with the attachment. :SATYABRATA SAHOO
*"----------------------------------------------------------------------
if recepients[] is initial.
return.
endif.
data: lo_send_request type ref to cl_bcs,
lo_document type ref to cl_document_bcs,
lo_sender_id type ref to if_sender_bcs,
lo_recipient type ref to if_recipient_bcs.
data: lo_bcs_exception type ref to cx_bcs.
data: lv_bcs_message type string,
lv_send_to_all type os_boolean,
lv_fields(10).
field-symbols: < fs_recipient > type ad_smtpadr.
*******************************************************************************
* build the file content
data: lo_struct_type type ref to cl_abap_structdescr,
lo_element_type type ref to cl_abap_elemdescr.
data: lt_components type cl_abap_structdescr=>component_table,
ls_field type dfies.
field-symbols: type abap_componentdescr.
data: lt_binary_text type solix_tab,
lv_text type string,
lv_size type so_obj_len.
* build the header data
lo_struct_type ?= cl_abap_typedescr=>describe_by_data( data_to_send ).
lt_components = lo_struct_type->get_components( ).
loop at lt_components assigning.
if sy-tabix gt 1.
concatenate lv_text cl_bcs_convert=>gc_tab into lv_text.
endif.
lo_element_type ?=-type.
ls_field = lo_element_type->get_ddic_field( ).
concatenate lv_text ls_field-scrtext_l into lv_text.
endloop.
concatenate lv_text cl_bcs_convert=>gc_crlf into lv_text.
* build the structure of the body
field-symbols: type any,
type any.
loop at data_to_send assigning.
loop at lt_components assigning.
if sy-tabix gt 1.
concatenate lv_text cl_bcs_convert=>gc_tab into lv_text.
endif.
assign component-name of structure to .
lv_fields =.
condense lv_fields.
* concatenate lv_text into lv_text.
concatenate lv_text lv_fields into lv_text.
endloop.
concatenate lv_text cl_bcs_convert=>gc_crlf into lv_text.
endloop.
try .
cl_bcs_convert=>string_to_solix(
exporting
iv_string = lv_text
iv_codepage = '4103' "suitable for MS Excel, leave empty"
iv_add_bom = abap_true
importing
et_solix = lt_binary_text
ev_size = lv_size ).
catch cx_bcs into lo_bcs_exception.
lv_bcs_message = lo_bcs_exception->get_text( ).
append lv_bcs_message to return.
exit.
endtry.
*******************************************************************************
* send an email
try .
clear: lo_send_request, lo_document, lo_sender_id.
lo_send_request = cl_bcs=>create_persistent( ).
lo_document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = email_body[]
i_subject = subject ).
if not data_to_send[] is initial.
lo_document->add_attachment(
i_attachment_type = 'XLS'
i_attachment_subject = subject
i_attachment_size = lv_size
i_att_content_hex = lt_binary_text ).
endif.
lo_send_request->set_document( lo_document ).
lo_sender_id = cl_cam_address_bcs=>create_internet_address( sender ).
lo_send_request->set_sender( lo_sender_id ).
* add recipients
loop at recepients assigning.
clear lo_recipient.
lo_recipient = cl_cam_address_bcs=>create_internet_address( ).
* add recipient with its respective attributes to send request
lo_send_request->add_recipient( i_recipient = lo_recipient
i_express = abap_true ).
endloop.
lo_send_request->set_status_attributes( i_requested_status = 'E'
i_status_mail = 'E' ).
lo_send_request->set_send_immediately( abap_true ).
lv_send_to_all = lo_send_request->send( i_with_error_screen = abap_true ).
if lv_send_to_all eq abap_true.
data: ls_return like line of return.
ls_return = text-001. "Success
append ls_return to return.
endif.
commit work.
catch cx_bcs into lo_bcs_exception.
lv_bcs_message = lo_bcs_exception->get_text( ).
append lv_bcs_message to return.
exit.
endtry.
endfunction.
============================================
Ref-http://techsplice.com/
and send out emails with the attachment.
Add the appropriate import parameters.
Add appropriate table parameters.
Source Code
====================================================
function zinttab_excl_email.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(SENDER) TYPE AD_SMTPADR
*" REFERENCE(SUBJECT) TYPE SO_OBJ_DES
*" TABLES
*" RECEPIENTS TYPE BCSY_SMTPA
*" RETURN TYPE TABLE_OF_STRINGS OPTIONAL
*" DATA_TO_SEND
*" EMAIL_BODY TYPE BCSY_TEXT
*"----------------------------------------------------------------------
*Function module that will take any internal table as input, convert in to XLS format
*and send out emails with the attachment. :SATYABRATA SAHOO
*"----------------------------------------------------------------------
if recepients[] is initial.
return.
endif.
data: lo_send_request type ref to cl_bcs,
lo_document type ref to cl_document_bcs,
lo_sender_id type ref to if_sender_bcs,
lo_recipient type ref to if_recipient_bcs.
data: lo_bcs_exception type ref to cx_bcs.
data: lv_bcs_message type string,
lv_send_to_all type os_boolean,
lv_fields(10).
field-symbols: < fs_recipient > type ad_smtpadr.
*******************************************************************************
* build the file content
data: lo_struct_type type ref to cl_abap_structdescr,
lo_element_type type ref to cl_abap_elemdescr.
data: lt_components type cl_abap_structdescr=>component_table,
ls_field type dfies.
field-symbols:
data: lt_binary_text type solix_tab,
lv_text type string,
lv_size type so_obj_len.
* build the header data
lo_struct_type ?= cl_abap_typedescr=>describe_by_data( data_to_send ).
lt_components = lo_struct_type->get_components( ).
loop at lt_components assigning
if sy-tabix gt 1.
concatenate lv_text cl_bcs_convert=>gc_tab into lv_text.
endif.
lo_element_type ?=
ls_field = lo_element_type->get_ddic_field( ).
concatenate lv_text ls_field-scrtext_l into lv_text.
endloop.
concatenate lv_text cl_bcs_convert=>gc_crlf into lv_text.
* build the structure of the body
field-symbols:
loop at data_to_send assigning
loop at lt_components assigning
if sy-tabix gt 1.
concatenate lv_text cl_bcs_convert=>gc_tab into lv_text.
endif.
assign component
lv_fields =
condense lv_fields.
* concatenate lv_text
concatenate lv_text lv_fields into lv_text.
endloop.
concatenate lv_text cl_bcs_convert=>gc_crlf into lv_text.
endloop.
try .
cl_bcs_convert=>string_to_solix(
exporting
iv_string = lv_text
iv_codepage = '4103' "suitable for MS Excel, leave empty"
iv_add_bom = abap_true
importing
et_solix = lt_binary_text
ev_size = lv_size ).
catch cx_bcs into lo_bcs_exception.
lv_bcs_message = lo_bcs_exception->get_text( ).
append lv_bcs_message to return.
exit.
endtry.
*******************************************************************************
* send an email
try .
clear: lo_send_request, lo_document, lo_sender_id.
lo_send_request = cl_bcs=>create_persistent( ).
lo_document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = email_body[]
i_subject = subject ).
if not data_to_send[] is initial.
lo_document->add_attachment(
i_attachment_type = 'XLS'
i_attachment_subject = subject
i_attachment_size = lv_size
i_att_content_hex = lt_binary_text ).
endif.
lo_send_request->set_document( lo_document ).
lo_sender_id = cl_cam_address_bcs=>create_internet_address( sender ).
lo_send_request->set_sender( lo_sender_id ).
* add recipients
loop at recepients assigning
clear lo_recipient.
lo_recipient = cl_cam_address_bcs=>create_internet_address(
* add recipient with its respective attributes to send request
lo_send_request->add_recipient( i_recipient = lo_recipient
i_express = abap_true ).
endloop.
lo_send_request->set_status_attributes( i_requested_status = 'E'
i_status_mail = 'E' ).
lo_send_request->set_send_immediately( abap_true ).
lv_send_to_all = lo_send_request->send( i_with_error_screen = abap_true ).
if lv_send_to_all eq abap_true.
data: ls_return like line of return.
ls_return = text-001. "Success
append ls_return to return.
endif.
commit work.
catch cx_bcs into lo_bcs_exception.
lv_bcs_message = lo_bcs_exception->get_text( ).
append lv_bcs_message to return.
exit.
endtry.
endfunction.
============================================
Ref-http://techsplice.com/
12 comments:
Thanks for sharing this Information, Got to learn new things from your Blog on SAP SD.
http://thecreatingexperts.com/sap-sd-training-in-chennai/
Thanks for sharing this Information, Got to learn new things from your Blog on SAP MM.
http://thecreatingexperts.com/sap-mm-training-in-chennai/
Thanks for sharing this Information, Got to learn new things from your Blog on SAP ABAP.
http://thecreatingexperts.com/sap-abap-training-in-chennai
This site was really very helpful for me and I really find it very interesting. Thanks a lot for sharing this information in this site. I really liked it very much. SAP Simple Finance Training
This site was really very helpful for me and I really find it very interesting. Thanks a lot for sharing this information on this site. I really liked it very much
thank regard
oracle fusion procurement online training
oracle fusion procurement training
لاشك ان شركه الحورس تعد افضل شركه خدمات منزليه التي منها (التنظيف/رش مبيدات/مكافحه حشرات/تسليك مجاري/كشف تسربات المياه/تنظيف خزانات..)وعديد من الخدمات التي تلزم البيت او الفله نحن بخدمتك عزيزي العميل.
شركه رش مبيدات بالطائف
شركه نقل اثاث وعفش بالطائف
شركه تنظيف بالطائف
شركه مكافحة حشرات بالطائف
شركه كشف تسربات المياه بالطائف
حيث شركتنا تتميز باداء الخدمه علي افضل وجهه حيث نعد
شركه تنظيف خزانات بالطائف
نقدم لك عزيزي العميل/ه الراحه التامه والصحه السليمه للحفاظ عليك من الامراض الخطيره
تقدم شركة الوسيله خدمات عديده بجميع مدن المملكه ومن خدمتنا:
شركة تنظيف منازل بالمدينة المنورة
شركة تنظيف خزانات بالمدينة المنورة
شركة تنظيف بينبع
شركة تنظيف بجدة
شركة تنظيف بالجبيل
شركة مكافحة حشرات بالطائف
شركة مكافحة حشرات بالمدينة المنورة
شركة مكافحة حشرات بالدمام
شركة تسليك مجارى بالدمام
تعد شركه ركن الهدي افضل شركه تقدم الخدمات والصيانه المنزليه بالمملكه العربيه السعوديه ومن الخدمات :
شركة جلى بلاط ورخام بالظهران
شركة تنظيف مسابح بالظهران
شركة تنظيف كنب بالدمام بالخبر
شركة مكافحة حشرات بالدمام بالخبر
شركة تنظيف مجالس بالاحساء
شركة تنظيف كنب بالاحساء
شركة مكافحة النمل الابيض بالقطيف
شركة عزل اسطح وخزانات بالقطيف
Thanks for sharing
Oracle Fusion Financials Training
CALFRE handles oracle fusion financials online training and its modules maintaining classroom based training with the self-paced videos. An expert having ten plus years of self-experience handles the training period through online and explains each and every point perfectly. We recently launched our institute in the USA and getting
the best reputation over there.
Oracle fusion Financials Training in hyderabad
Oracle Fusion Financials online Training in hyderabad
good post
شركة مكافحة النمل الابيض بالدمام
شركة مكافحة حشرات بالدمام
Real time SAP Training in Chennai with lots of updates..
Best SAP Training in Chennai | SAP Training Center in Chennai | SAP Training Institute in Chennai
Post a Comment