Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

ALV out put to be downloaded in Background to apps server

Former Member
0 Kudos

Hello All,

I want to download ALV output to APPL Server in TAB delimited format.

I am able to get the internal table values usinf open record set and transfering.

But the real issue is they are having diffrent layouts and according to layout i need to down the file.

Is it possible ? if please suggest.

Rgds,

O

1 REPLY 1

FredericGirod
Active Contributor
0 Kudos

Hi,

I have an old code that I have wrote to transform ALV in HTML in background to send the result by email. Maybe that could help you (don't be rude, it's one of my first ALV program ).

The comments are in french, but, you could understand.

I hope that could help you

Rgd

Frédéric

* Complete.
  call function 'LVC_FIELDCATALOG_MERGE'
       exporting
            i_structure_name   = 'ZGRE000_S2'
            i_bypassing_buffer = ' '
            i_buffer_active    = ' '
       changing
            ct_fieldcat      = itab_fieldcatalog.

  call function 'LVC_FIELDCAT_COMPLETE'
    EXPORTING
*     I_COMPLETE             =
      IS_LAYOUT              = v_es_layout
      I_REFRESH_BUFFER       = ''
      I_BUFFER_ACTIVE        = ''
*   IMPORTING
*     E_EDIT                 =
    changing
      ct_fieldcat            = itab_fieldcatalog.

  call function 'LVC_SORT_COMPLETE'
    exporting
      it_fieldcat       = itab_fieldcatalog
    changing
      ct_sort           = itab_mt_sort.

  call function 'ALV_DATA_EXPORT'
    exporting
      i_report                = ''
      IT_FIELDCAT             = itab_fieldcatalog
    tables
      it_data                 = itab_zgre000_s2.



* Recherche de la variante d'affichage.
  move : sy-repid to struct_variant-report ,
         sy-uname to struct_variant-username ,
         '2'      to struct_variant-handle.
  if p_vgrid ne space.
    move p_vgrid to struct_variant-variant.
  endif.


* Ne pas demander d'explication, merci :)
  get reference of itab_zgre000_s2 into mt_outtab.

* Créé l'objet variant.
  create object m_cl_variant
         exporting
           it_outtab             = mt_outtab
           it_fieldcatalog       = itab_fieldcatalog
           it_sort               = itab_mt_sort
           it_filter             = itab_mt_filter
           is_variant            = struct_variant
           is_layout             = v_es_layout
           i_variant_save        = v_e_var_save
           i_variant_default     = v_e_var_def.
  move : 'A' to v_e_var_save ,
         'X' to v_e_var_def .


  call method m_cl_variant->set_values
       exporting it_outtab             = mt_outtab
                 it_fieldcatalog       = itab_fieldcatalog
                 it_sort               = itab_mt_sort
                 it_filter             = itab_mt_filter
                 is_variant            = struct_variant
                 is_layout             = v_es_layout
                 i_variant_save        = v_e_var_save
                 i_variant_default     = v_e_var_def.

   loop at itab_fieldcatalog into tmp_fieldcatalog
        where tabname ne space.
     exit.
   endloop.

* Recherche de la variante.
  call method m_cl_variant->load_variant
       exporting i_tabname          = tmp_fieldcatalog-tabname
                 i_bypassing_buffer = 'X'
                i_dialog           = space.

  create data  mt_ct00 like itab_zgre000_s2.
  create data  mt_ct01 like itab_zgre000_s2.
  create data  mt_ct02 like itab_zgre000_s2.
  create data  mt_ct03 like itab_zgre000_s2.
  create data  mt_ct04 like itab_zgre000_s2.
  create data  mt_ct05 like itab_zgre000_s2.
  create data  mt_ct06 like itab_zgre000_s2.
  create data  mt_ct07 like itab_zgre000_s2.
  create data  mt_ct08 like itab_zgre000_s2.
  create data  mt_ct09 like itab_zgre000_s2.

  assign mt_ct00->* to <lt_ct00>.
  assign mt_ct01->* to <lt_ct01>.
  assign mt_ct02->* to <lt_ct02>.
  assign mt_ct03->* to <lt_ct03>.
  assign mt_ct04->* to <lt_ct04>.
  assign mt_ct05->* to <lt_ct05>.
  assign mt_ct06->* to <lt_ct06>.
  assign mt_ct07->* to <lt_ct07>.
  assign mt_ct08->* to <lt_ct08>.
  assign mt_ct09->* to <lt_ct09>.


* Recherche des valeurs à partir de la variante sélectionnée.
  call method m_cl_variant->get_values
       importing es_variant     = struct_variant
         et_fieldcatalog        = itab_fieldcatalog
         et_sort                = itab_mt_sort
         et_filter              = itab_mt_filter
         es_layout              = v_es_layout
         et_grouplevels_filter  = mt_grouplevels_filter
         e_variant_save         = v_e_var_save
         e_variant_default      = v_e_var_def.

  call function 'LVC_SORT_APPLY'
    exporting
      it_sort         = itab_mt_sort
*     I_AS_TEXT       = 'X'
*     I_STABLE        = 'X'
    tables
      ct_data         = itab_zgre000_s2.

  call function 'LVC_TRANSFER_TO_KKBLO'
    exporting
      it_sort_lvc                     = itab_mt_sort
      it_grouplevels_lvc              = mt_grouplevels_filter
    importing
      et_sort_kkblo                   = itab_lt_sort
      et_grouplevels_kkblo            = itab_lt_grouplevels
    exceptions
      it_data_missing                 = 1
      it_fieldcat_lvc_missing         = 2
      others                          = 3.

  call function 'ALV_GROUPLEVELS_GET'
    exporting
      i_subtotals_only          = 'X'
      it_sort                   = itab_lt_sort
      i_subtract_counter        = 'X'
    importing
      et_groups                 = itab_lt_grouplevels
    tables
      t_outtab                  = itab_zgre000_s2.

  call function 'LVC_TRANSFER_FROM_KKBLO'
    exporting
      it_grouplevels_kkblo            = itab_lt_grouplevels
    importing
      et_grouplevels_lvc              = mt_grouplevels_filter
    exceptions
      it_data_missing                 = 1
      others                          = 2.


* Recupération des totaux.
  call function 'LVC_TOTALS_GET'
    exporting
      it_sort                  = itab_mt_sort
      is_layout                = v_es_layout
      it_filter_index          = itab_mt_filter_i
    tables
      it_data                  = itab_zgre000_s2
      et_collect00             = <lt_ct00>
      et_collect01             = <lt_ct01>
      et_collect02             = <lt_ct02>
      et_collect03             = <lt_ct03>
      et_collect04             = <lt_ct04>
      et_collect05             = <lt_ct05>
      et_collect06             = <lt_ct06>
      et_collect07             = <lt_ct07>
      et_collect08             = <lt_ct08>
      et_collect09             = <lt_ct09>
    changing
      cs_total_options         = ms_total_options
*      ct_fieldcat              = mt_fieldcatalog
      ct_fieldcat              = itab_fieldcatalog
      ct_grouplevels           = mt_grouplevels_filter
      c_calculate_totals       = m_calculate_totals
      c_sumlevel               = m_sumlevel .

* Converti dans un language comprehensible par SAP.
  call function 'LVC_TABLE_FOR_DISPLAY'
    exporting
      it_fieldcat                    = itab_fieldcatalog
      it_sort                        = itab_mt_sort
      it_filter                      = itab_mt_filter
      is_total_options               = ms_total_options
      is_layout                      = v_es_layout
    importing
      et_lvc_data                    = itab_mt_data
      et_lvc_info                    = itab_mt_info
    tables
      it_data                        = itab_zgre000_s2
      it_collect00                   = <lt_ct00>
      it_collect01                   = <lt_ct01>
      it_collect02                   = <lt_ct02>
      it_collect03                   = <lt_ct03>
      it_collect04                   = <lt_ct04>
      it_collect05                   = <lt_ct05>
      it_collect06                   = <lt_ct06>
      it_collect07                   = <lt_ct07>
      it_collect08                   = <lt_ct08>
      it_collect09                   = <lt_ct09>
    changing
      ct_grouplevels                 = mt_grouplevels_filter
    exceptions
      fieldcat_not_complete          = 1
      others                         = 2.


  if sy-subrc ne space.
    write : /1 'Probleme de convertion.'.
    stop.
  endif.



* Convertie en HTML.
  call function 'LVC_ALV_CONVERT_TO_HTML'
    exporting
      it_data                       = itab_mt_data
      it_info                       = itab_mt_info
      i_file_dialog                 = ' '
    importing
      et_html                       = itab_html.