Application Development and Automation 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: 
Read only

Apply ALV variant before export file in background task

Former Member
0 Likes
1,609

Hi all,

I'm working on an ALV report.

As my report should deal with a great amount of data, it's sometimes running in background.

Users want the result to be sent by mail (in .CSV format so that they can use it in excel).

For now, the sending is OK but the file contains all fields of the internal table (no specific filter, no sort...).

How can i apply ALV variant (i.e keeping some of the fields, filter the list an so on) to the internal table before i build the file ?

Thanks

Hi all,

I'm working on an ALV report.

As my report should deal with a great amount of data, it's sometimes running in background.

Users want the result to be sent by mail (in .CSV format so that they can use it in excel).

For now, the sending is OK but the file contains all fields of the internal table (no specific filter, no sort...).

How can i apply ALV variant (i.e keeping some of the fields, filter the list an so on) to the internal table before i build the file ?

Thanks

6 REPLIES 6
Read only

FredericGirod
Active Contributor
0 Likes
1,135

Salut Jérôme,

un vieux (très vieux) code que j'avais fait.

le but était d'envoyer par email le résultat d'un ALV grid.

il t'en manque une partie, mais le principal est dedans


*----------------------------------------------------------------------*
*   Procédure P_GEN_HTML.                                              *
*----------------------------------------------------------------------*
*   Génération d'un email en HTML.                                     *
*----------------------------------------------------------------------*
form p_gen_html.


 data : struct_zgre000_s2 type zgre000_s2 ,
        v_es_layout       type lvc_s_layo ,
        v_e_var_save(1) ,
        v_e_var_def(1) ,
        m_calculate_totals(1) value 'X' ,
        itab_mt_data      type lvc_t_data ,
        itab_mt_info      type lvc_t_info ,
        itab_mt_sort      type lvc_t_sort ,
        itab_mt_filter    type lvc_t_filt ,
        itab_mt_filter_i  type lvc_t_fidx ,
        itab_html         type swl_html_t ,
        m_cl_variant      type ref to cl_alv_variant ,
        mt_outtab         type ref to data ,
        object_hd_change  like sood1 occurs 0 with header line,
        objpara           like selc  occurs 0 with header line,
        receivers         like zbc_receivers occurs 0 with header line ,
        ms_total_options      type lvc_s_toto,
        mt_grouplevels_filter type lvc_t_grpl ,
        m_sumlevel            type i ,

        itab_lt_grouplevels type kkblo_t_grouplevels ,
        itab_lt_sort        type kkblo_t_sortinfo.

  field-symbols: <lt_ct00> type standard table,
                 <lt_ct01> type standard table,
                 <lt_ct02> type standard table,
                 <lt_ct03> type standard table,
                 <lt_ct04> type standard table,
                 <lt_ct05> type standard table,
                 <lt_ct06> type standard table,
                 <lt_ct07> type standard table,
                 <lt_ct08> type standard table,
                 <lt_ct09> type standard table.


* Ref the field-symbols.
  data mt_ct00 type ref to data .
  data mt_ct01 type ref to data .
  data mt_ct02 type ref to data .
  data mt_ct03 type ref to data .
  data mt_ct04 type ref to data .
  data mt_ct05 type ref to data .
  data mt_ct06 type ref to data .
  data mt_ct07 type ref to data .
  data mt_ct08 type ref to data .
  data mt_ct09 type ref to data .



  v_gjahr1 = p_gjahr + 1.
  v_gjahr2 = p_gjahr + 2.
  v_gjahr3 = p_gjahr + 3.

* Alimente la table ITAB_ZGRE000_S2.
  loop at itab_otp_grid.
    move : itab_otp_grid-astnr to struct_zgre000_s2-zdemandeur ,
           itab_otp_grid-astna to struct_zgre000_s2-zdemandeurt ,
           itab_otp_grid-pspn  to struct_zgre000_s2-zprojet ,
           itab_otp_grid-pspn2 to struct_zgre000_s2-zotp ,
           itab_otp_grid-post1 to struct_zgre000_s2-zdesotp ,
           itab_otp_grid-pspnr to struct_zgre000_s2-zotp2 ,
           itab_otp_grid-stat  to struct_zgre000_s2-zstatut ,
           itab_otp_grid-usr02 to struct_zgre000_s2-zoneutil ,
           itab_otp_grid-budgt to struct_zgre000_s2-zbudgettotal ,
           itab_otp_grid-engag to struct_zgre000_s2-zengagtotal ,
           itab_otp_grid-dispo to struct_zgre000_s2-zdispototal ,
           itab_otp_grid-depen to struct_zgre000_s2-zdepentotal ,
           itab_otp_grid-budgn to struct_zgre000_s2-zbudget ,
           itab_otp_grid-le    to struct_zgre000_s2-zlatest ,
           itab_otp_grid-depea to struct_zgre000_s2-zdepense ,
           itab_otp_grid-pourc to struct_zgre000_s2-zpourcen ,
           itab_otp_grid-budg1 to struct_zgre000_s2-zbudget1 ,
           itab_otp_grid-budg2 to struct_zgre000_s2-zbudget2 ,
           itab_otp_grid-budg3 to struct_zgre000_s2-zbudget3 ,
           itab_otp_grid-natur to struct_zgre000_s2-znature.
    append struct_zgre000_s2 to itab_zgre000_s2.
  endloop.


  refresh itab_fieldcatalog.

* Alimentation de la table ITAB_FIELDCATALOG.
  call function 'LVC_FIELDCATALOG_MERGE'
       exporting
            i_structure_name   = 'ZGRE000_S2'
            i_bypassing_buffer = ' '
            i_buffer_active    = ' '
       changing
            ct_fieldcat      = itab_fieldcatalog.

* Les modifications des colonnes.
  loop at itab_fieldcatalog into tmp_fieldcatalog.
    case tmp_fieldcatalog-fieldname.
      when 'ZDEMANDEUR'.
        move : ' '            to tmp_fieldcatalog-do_sum ,
               'Demandeur'    to tmp_fieldcatalog-scrtext_s ,
               'Demandeur'    to tmp_fieldcatalog-scrtext_m ,
               'Demandeur'    to tmp_fieldcatalog-scrtext_l ,
               v_zero         to tmp_fieldcatalog-no_zero ,
               '10'           to tmp_fieldcatalog-outputlen .
      when 'ZDEMANDEURT'.
        move : ' '            to tmp_fieldcatalog-do_sum ,
               'Demandeur'    to tmp_fieldcatalog-scrtext_s ,
               'Demandeur'    to tmp_fieldcatalog-scrtext_m ,
               'Demandeur'    to tmp_fieldcatalog-scrtext_l ,
               v_zero         to tmp_fieldcatalog-no_zero ,
               '30'           to tmp_fieldcatalog-outputlen .
      when 'ZPROJET'.
        move : ' '            to tmp_fieldcatalog-do_sum ,
               'Projet'       to tmp_fieldcatalog-scrtext_s ,
               'Projet'       to tmp_fieldcatalog-scrtext_m ,
               'Projet'       to tmp_fieldcatalog-scrtext_l ,
               v_zero         to tmp_fieldcatalog-no_zero ,
               '10'           to tmp_fieldcatalog-outputlen .
      when 'ZOTP'.
        move : ' '            to tmp_fieldcatalog-do_sum ,
               'OTP'          to tmp_fieldcatalog-scrtext_s ,
               'OTP'          to tmp_fieldcatalog-scrtext_m ,
               'OTP'          to tmp_fieldcatalog-scrtext_l ,
               v_zero         to tmp_fieldcatalog-no_zero ,
               '20'           to tmp_fieldcatalog-outputlen .
      when 'ZDESOTP'.
        move : ' '            to tmp_fieldcatalog-do_sum ,
               'Libellé OTP'  to tmp_fieldcatalog-scrtext_s ,
               'Libellé OTP'  to tmp_fieldcatalog-scrtext_m ,
               'Libellé OTP'  to tmp_fieldcatalog-scrtext_l ,
               v_zero         to tmp_fieldcatalog-no_zero ,
               '20'           to tmp_fieldcatalog-outputlen .
      when 'ZOTP2'.
        move : ' '            to tmp_fieldcatalog-do_sum ,
               'OTP niveau 2' to tmp_fieldcatalog-scrtext_s ,
               'OTP niveau 2' to tmp_fieldcatalog-scrtext_m ,
               'OTP niveau 2' to tmp_fieldcatalog-scrtext_l ,
               v_zero         to tmp_fieldcatalog-no_zero ,
               '20'           to tmp_fieldcatalog-outputlen .
      when 'ZSTATUT'.
        move : ' '            to tmp_fieldcatalog-do_sum ,
               'Statut'       to tmp_fieldcatalog-scrtext_s ,
               'Statut'       to tmp_fieldcatalog-scrtext_m ,
               'Statut'       to tmp_fieldcatalog-scrtext_l ,
               v_zero         to tmp_fieldcatalog-no_zero ,
               '10'           to tmp_fieldcatalog-outputlen .
      when 'ZONEUTIL'.
        move : ' '            to tmp_fieldcatalog-do_sum ,
               'Zone util'    to tmp_fieldcatalog-scrtext_s ,
               'Zone util'    to tmp_fieldcatalog-scrtext_m ,
               'Zone util'    to tmp_fieldcatalog-scrtext_l ,
               v_zero         to tmp_fieldcatalog-no_zero ,
               '10'           to tmp_fieldcatalog-outputlen .
      when 'ZNATURE'.
        move : ' '            to tmp_fieldcatalog-do_sum ,
               'Nature'       to tmp_fieldcatalog-scrtext_s ,
               'Nature'       to tmp_fieldcatalog-scrtext_m ,
               'Nature'       to tmp_fieldcatalog-scrtext_l ,
               v_zero         to tmp_fieldcatalog-no_zero ,
               '10'           to tmp_fieldcatalog-outputlen .
      when 'ZBUDGETTOTAL'.
        move : 'X'            to tmp_fieldcatalog-do_sum ,
               'Bud. total'   to tmp_fieldcatalog-scrtext_s ,
               'Budget total' to tmp_fieldcatalog-scrtext_l ,
               v_zero         to tmp_fieldcatalog-no_zero ,
               '20'           to tmp_fieldcatalog-outputlen .
      when 'ZENGAGTOTAL'.
        move : 'X'            to tmp_fieldcatalog-do_sum ,
               'Eng. total'   to tmp_fieldcatalog-scrtext_s ,
               'Engagement total' to tmp_fieldcatalog-scrtext_l ,
               v_zero         to tmp_fieldcatalog-no_zero ,
               '20'           to tmp_fieldcatalog-outputlen .
      when 'ZDISPOTOTAL'.
        move : 'X'            to tmp_fieldcatalog-do_sum ,
               'Disp total'  to tmp_fieldcatalog-scrtext_s ,
               'Disponible total' to tmp_fieldcatalog-scrtext_l ,
               v_zero         to tmp_fieldcatalog-no_zero ,
               '20'           to tmp_fieldcatalog-outputlen .
      when 'ZDEPENTOTAL'.
        move : 'X'            to tmp_fieldcatalog-do_sum ,
               'Dep. total'   to tmp_fieldcatalog-scrtext_s ,
               v_zero         to tmp_fieldcatalog-no_zero ,
               '20'           to tmp_fieldcatalog-outputlen .
        concatenate 'Depenses totales'
                    '_'
                    p_perio
                    '.'
                    p_gjahr
                    into tmp_fieldcatalog-scrtext_l.
      when 'ZBUDGET'.
        move : 'X'            to tmp_fieldcatalog-do_sum ,
                v_zero        to tmp_fieldcatalog-no_zero ,
               '20'           to tmp_fieldcatalog-outputlen .
        concatenate 'Bud '
                    p_gjahr
                    into tmp_fieldcatalog-scrtext_s
                    separated by ' '.
        concatenate 'Budget Exercice:'
                    p_gjahr
                    'Version:'
                    p_vers1
                    into tmp_fieldcatalog-scrtext_l
                    separated by ' '.
      when 'ZLATEST'.
        move : 'X'            to tmp_fieldcatalog-do_sum ,
               'Latest'       to tmp_fieldcatalog-scrtext_s ,
               v_zero         to tmp_fieldcatalog-no_zero ,
               '20'           to tmp_fieldcatalog-outputlen .
        concatenate 'Latest Exercice:'
                    p_gjahr
                    'Version:'
                    p_vers2
                    into tmp_fieldcatalog-scrtext_l
                    separated by ' '.
      when 'ZDEPENSE'.
        move : 'X'            to tmp_fieldcatalog-do_sum ,
               v_zero         to tmp_fieldcatalog-no_zero ,
               '20'           to tmp_fieldcatalog-outputlen .
        concatenate 'Dep'
                    p_gjahr
                    into tmp_fieldcatalog-scrtext_s
                    separated by ' '.
        concatenate 'Depense Exercice:'
                    p_gjahr
                    into tmp_fieldcatalog-scrtext_l
                    separated by ' '.
      when 'ZPOURCEN'.
        move : ' '            to tmp_fieldcatalog-do_sum ,
               '% Dep/LE'     to tmp_fieldcatalog-scrtext_s ,
               'Pourcentage dépense VS LE'
                              to tmp_fieldcatalog-scrtext_l ,
               v_zero         to tmp_fieldcatalog-no_zero ,
               '20'           to tmp_fieldcatalog-outputlen .
      when 'ZBUDGET1'.
        move : 'X'            to tmp_fieldcatalog-do_sum ,
               v_zero         to tmp_fieldcatalog-no_zero ,
               '20'           to tmp_fieldcatalog-outputlen .
        concatenate 'Bud'
                    v_gjahr1
                    into tmp_fieldcatalog-scrtext_s
                    separated by ' '.
        concatenate 'Budget Exercice:'
                    v_gjahr1
                    into tmp_fieldcatalog-scrtext_l
                    separated by ' '.
      when 'ZBUDGET2'.
        move : 'X'            to tmp_fieldcatalog-do_sum ,
               v_zero         to tmp_fieldcatalog-no_zero ,
               '20'           to tmp_fieldcatalog-outputlen .
        concatenate 'Bud'
                    v_gjahr2
                    into tmp_fieldcatalog-scrtext_s
                    separated by ' '.
        concatenate 'Budget Exercice:'
                    v_gjahr2
                    into tmp_fieldcatalog-scrtext_l
                    separated by ' '.
      when 'ZBUDGET3'.
        move : 'X'            to tmp_fieldcatalog-do_sum ,
               v_zero         to tmp_fieldcatalog-no_zero ,
               '20'           to tmp_fieldcatalog-outputlen .
        concatenate 'Bud'
                    v_gjahr3
                    into tmp_fieldcatalog-scrtext_s
                    separated by ' '.
        concatenate 'Budget Exercice:'
                    v_gjahr3
                    into tmp_fieldcatalog-scrtext_l
                    separated by ' '.
    endcase.
    move 'X' to tmp_fieldcatalog-tech_comp.
    modify itab_fieldcatalog from tmp_fieldcatalog.
  endloop.

  call function 'WS_DOWNLOAD'
    EXPORTING
      FILENAME                      =
'\RNEMS0025BU_girodf1$Desktopit_field.txt'
      FILETYPE                      = 'DAT'
    tables
      data_tab                      = itab_fieldcatalog.

  data : begin of it_tmp_data occurs 1000 ,
           buff(136) ,
           zbudgetttotal(20) ,
           zengagtotal(20) ,
           zdispottotal(20) ,
           zdepentotal(20) ,
           zbudget(20) ,
           zlatest(20) ,
           zdepense(20) ,
           zpourcen(20) ,
           zbudget1(20) ,
           zbudget2(20) ,
           zbudget3(20) ,
           waers(5) ,
         end   of it_tmp_data.
break girodf1.
  loop at itab_zgre000_s2 into struct_zgre000_s2.
    move struct_zgre000_s2+0(136) to it_tmp_data-buff .
    move-corresponding struct_zgre000_s2 to it_tmp_data.
    append it_tmp_data.
  endloop.

  call function 'DOWNLOAD'
    EXPORTING
*     BIN_FILESIZE                  = ' '
*     CODEPAGE                      = ' '
      FILENAME                      =
'\RNEMS0025BU_girodf1$Desktopit_data.txt'
      FILETYPE                      = 'DAT'
*     ITEM                          = ' '
*     MODE                          = ' '
*     WK1_N_FORMAT                  = ' '
*     WK1_N_SIZE                    = ' '
*     WK1_T_FORMAT                  = ' '
*     WK1_T_SIZE                    = ' '
*     FILEMASK_MASK                 = ' '
*     FILEMASK_TEXT                 = ' '
*     FILETYPE_NO_CHANGE            = ' '
*     FILEMASK_ALL                  = ' '
*     FILETYPE_NO_SHOW              = ' '
      SILENT                        = 'S'
*     COL_SELECT                    = ' '
*     COL_SELECTMASK                = ' '
*     NO_AUTH_CHECK                 = ' '
*   IMPORTING
*     ACT_FILENAME                  =
*     ACT_FILETYPE                  =
*     FILESIZE                      =
*     CANCEL                        =
    tables
      data_tab                      = it_tmp_data.


*  call function 'DOWNLOAD'
*    EXPORTING
*      FILENAME                      =
*'\RNEMS0025BU_girodf1$Desktopit_data.txt'
*      FILETYPE                      = 'ASC'
*    tables
*      data_tab                      = itab_zgre000_s2.
*

* 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.

* Envois par email.
  move : 'HTM'  to object_hd_change-file_ext ,
         'Liste des commandes passées sur Immobilisation via PM'
                to object_hd_change-objdes.
  append object_hd_change.


  call function 'WS_DOWNLOAD'
    EXPORTING
      FILENAME                      =
'\RNEMS0025BU_girodf1$Desktopmt_data.txt'
      FILETYPE                      = 'DAT'
    tables
      data_tab                      = itab_mt_data.
  call function 'WS_DOWNLOAD'
    EXPORTING
      FILENAME                      =
'\RNEMS0025BU_girodf1$Desktopmt_info.txt'
      FILETYPE                      = 'DAT'
    tables
      data_tab                      = itab_mt_info.

  data : it_var type table of disvariant with header line.
  move-corresponding struct_variant to it_var.
  append it_var.
  call function 'WS_DOWNLOAD'
    EXPORTING
      FILENAME                      =
'\RNEMS0025BU_girodf1$Desktopit_var.txt'
      FILETYPE                      = 'DAT'
    tables
      data_tab                      = it_var.




*stop.

* Liste des personnes à qui on envoye le email.
  select bname
         into receivers-uname
         from usr02
         where bname in s_uname.
    append receivers.
  endselect.


* Send mail.
  call function 'Z_BC_ENVOI_EMAIL'
       exporting
           object_hd_change           = object_hd_change
           object_type                = 'RAW'
           owner                      = sy-uname
       tables
           objcont                    = itab_html
           receivers                  = receivers
       exceptions
           others                     = 01.



endform.                     " P_GEN_HTML.

Read only

Former Member
0 Likes
1,135

Merci !

Je fait un essai de suite

Read only

Former Member
0 Likes
1,135

Frédéric,

Merci pour ton aide, malheureusement il semble que ma version SAP (4.7) ne soit pas compatible avec ton exemple (les interface de méthode ne correspondent pas)

J'essai de retravailler le code, mais ça n'est pas simple....

Read only

0 Likes
1,135

Bonjour,

Alors ?

Read only

Former Member
0 Likes
1,135

Bonjour,

Je n'ai pas réussi à faire matcher le code...

J'ai temporairement abandonner la recherche (appeler sur d'autres sujets plus urgents)

Cordialement

Read only

0 Likes
1,135

D'accord. En fait je suis tombé sur ce post par hasard. C'est la première fois que j'en voyais un en français. C'est pour ça que j'ai réagi.

Moi je suis abapeur sur Paris depuis 3 ans pour une SSII (capgemini).

Peut être à bientôt sur le forum.

Cordialement,

Chaouki