Skip to Content
author's profile photo Former Member
Former Member

Infoset Query report output as excel attached mail(in background - more than 255 char)

I am trying to send email with excel attachment for the output of a Query report program, which is run in background. I am able to achieve this for a line width less than or equal to 255 chars, but not more than that. As we will be running Infoset Queries with dynamic variant, wide lists, need a solution for this.

I have tried the below 2 approaches:

1. Writing the query output to the spool and sending this as excel attachments using FMs:






But, the excel file is getting truncated with limited width of 255 char.

2. Getting runtime ALV object using:

t_data = <lt_data>.

But, the datatype of the alv report(field catalog) is unknown/dynamic. So I am not getting the way to fetch the obtained data, convert into excel for sending email.

Please suggest a way to achieve this, if anybody has encountered such a situation.

Thank you,


Add comment
10|10000 characters needed characters exceeded

2 Answers

  • Posted on Jun 06, 2017 at 02:02 PM

    cl_salv_bs_runtime_info is also able to retrieve the field catalog and more informations (cl_salv_bs_runtime_info=>get_metadata) to analyze the returned dynamic internal table (cl_salv_bs_runtime_info=>get_data[_ref]). You could then use class like cl_salv_ex_util, cl_salv_bs_tt_util to generate dynamically an xml (type mhtml) attachment.

    * Get ref to data
    lr_data = cl_salv_bs_runtime_info=>get_data_ref( ).
    * Get metadata (layout)
    ls_metadata = cl_salv_bs_runtime_info=>get_metadata( ).
    * Rebuild the ALV
    lr_result_data = cl_salv_ex_util=>factory_result_data_table(
      r_data                 = lr_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/xml
        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
        xml           = lv_xml ).

    You should be able to adapt for your requirements just by setting some break-points and debug an export to mhtml from any standard ALV grid program of your system.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Raymond,

      I have used the method get_data() and I can see the data in a reference variable <lt_data> using the following code in debugging mode.

      But I am not getting how to obtain the data in a suitable internal table, as this will dynamic, based on the query variants.

      Also, I did not find any class like CL_XLSX_DOCUMENT.

      cl_salv_bs_runtime_info=>get_data(IMPORTINGt_data = <lt_data>.
  • Posted on Jun 08, 2017 at 06:17 AM

    As Raymond said: "use a dummy printer that allows a report width of 1023..." (1023 is the max width of an ABAP list spool)

    Add comment
    10|10000 characters needed characters exceeded

    • There is a "format type" available in the print dialog (this print dialog may be displayed when you run the query in background). You may create a format type using transaction SPAD, define it as being a list format, with width 1023.