12-01-2017 10:05 AM
Hi Guys,
My requirement is to read SAP Query generated ALV Spool list (Each row contains Information more than 255 Char length) and send mail only in an Excel.
Currently I am using FM 'RSPO_RETURN_ABAP_SPOOLJOB’, but it truncates the data exceeds more than 255 char. I even tried FM CONVERT_ABAPSPOOLJOB_2_PDF, although it works fine to solve length issue, I couldn't able send it in Excel format through email.
Please help me to solve this puzzle.
12-01-2017 12:27 PM
Don't generate a spool, use cl_salv_bs_runtime_info instead.
NB: You can even generate a mtml file with this class, cl_salv_ex_util and cl_salv_bs_tt_util.
* Set Handler
call method cl_salv_bs_runtime_info=>set
exporting
display = abap_false
metadata = abap_true
data = abap_true.
* Call report
submit (i_report)
using selection-set (i_variant)
and return.
* get data back
call method cl_salv_bs_runtime_info=>get_data_ref
importing
r_data = gr_data.
* get medtadata back
ls_metadata = cl_salv_bs_runtime_info=>get_metadata( ).
* simulate the ALV
lr_result_data = cl_salv_ex_util=>factory_result_data_table(
r_data = gr_data
s_layout = ls_metadata-s_layout
t_fieldcatalog = ls_metadata-t_fcat
t_sort = ls_metadata-t_sort
t_filter = ls_metadata-t_filter ).
* convert to mhtml
cl_salv_bs_tt_util=>if_salv_bs_tt_util~transform(
exporting
xml_version = if_salv_bs_xml=>version
r_result_data = lr_result_data
xml_type = if_salv_bs_xml=>c_type_mhtml
xml_flavour = if_salv_bs_c_tt=>c_tt_xml_flavour_export
gui_type = if_salv_bs_xml=>c_gui_type_gui
importing
xml = e_xml ).
* be clean
cl_salv_bs_runtime_info=>clear_all( )
12-01-2017 12:27 PM
Don't generate a spool, use cl_salv_bs_runtime_info instead.
NB: You can even generate a mtml file with this class, cl_salv_ex_util and cl_salv_bs_tt_util.
* Set Handler
call method cl_salv_bs_runtime_info=>set
exporting
display = abap_false
metadata = abap_true
data = abap_true.
* Call report
submit (i_report)
using selection-set (i_variant)
and return.
* get data back
call method cl_salv_bs_runtime_info=>get_data_ref
importing
r_data = gr_data.
* get medtadata back
ls_metadata = cl_salv_bs_runtime_info=>get_metadata( ).
* simulate the ALV
lr_result_data = cl_salv_ex_util=>factory_result_data_table(
r_data = gr_data
s_layout = ls_metadata-s_layout
t_fieldcatalog = ls_metadata-t_fcat
t_sort = ls_metadata-t_sort
t_filter = ls_metadata-t_filter ).
* convert to mhtml
cl_salv_bs_tt_util=>if_salv_bs_tt_util~transform(
exporting
xml_version = if_salv_bs_xml=>version
r_result_data = lr_result_data
xml_type = if_salv_bs_xml=>c_type_mhtml
xml_flavour = if_salv_bs_c_tt=>c_tt_xml_flavour_export
gui_type = if_salv_bs_xml=>c_gui_type_gui
importing
xml = e_xml ).
* be clean
cl_salv_bs_runtime_info=>clear_all( )
12-04-2017 10:10 AM
12-01-2017 2:37 PM
Just my opinion, but I think it would be easier to just rewrite the query into a report. The time saved by generating an excel directly from data should easily make up for the time to write the report. A SAP query report isn’t usually that complex.