Skip to Content
0

Read ALV Spool List more than 255 Chars and send it in Excel

Dec 01, 2017 at 10:05 AM

132

avatar image
Former Member

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.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Raymond Giuseppi
Dec 01, 2017 at 12:27 PM
3

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( )

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Raymond,

Thanks a lot for you input, it worked. :).

0
Mike Pokraka Dec 01, 2017 at 02:37 PM
0

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.

Share
10 |10000 characters needed characters left characters exceeded