ALV Variant fields
Wassup !
A need to create a file in same as time as a display an ALV. In selection screen there is a field that the user can load a variant. I need to create the file with the same fields displayed in ALV, How can I discover witch fields will appear in screen.
There is a table for that ?
A FM ?
Thx all.
Point will be rewards. !!
Wassup ...
I hope the following code helps ...
{ variante-report = sy-repid.
variante-variant = p_vari.
layout-colwidth_optimize = 'X'.
layout-zebra = 'X'.
IF NOT p_vari IS INITIAL.
CALL FUNCTION 'REUSE_ALV_VARIANT_SELECT'
EXPORTING
i_dialog = ' '
it_default_fieldcat = t_fieldcat
i_layout = layout
IMPORTING
ET_FIELDCAT = t_fieldcat
CHANGING
cs_variant = variante
EXCEPTIONS
WRONG_INPUT = 1
FC_NOT_COMPLETE = 2
NOT_FOUND = 3
PROGRAM_ERROR = 4
OTHERS = 5.
ELSE.
LOOP AT t_fieldcat assigning <fs_fieldcat>.
CLEAR: <fs_fieldcat>-no_out.
ENDLOOP.
ENDIF.
CALL FUNCTION 'GET_COMPONENT_LIST'
EXPORTING
program = sy-repid
fieldname = 'T_LISTA'
tables
components = tl_comp.
CLEAR: vl_file.
First u get the variant with 'REUSE_ALV_VARIANT_SELECT. After that u discovery with fields will be shown with that variant.
Similar Messages
-
How to find number of columns used in a ALV variant
I need to know how many column is active ( will be shown in the ALV report ) related to a specific ALV Variant.
Example :
The structure of my internal table has 147 columns.
The user in a specific ALV variant has chosen 25 columns of those 147 colums, so I need to know that this ALV variant will show 25 columns.
Thanks! JoHi Max,
Thanks for hints.
Finnally I did the verification at the beginning of my process.
Because I need the information before getting the data, so I called the METHOD with a "dummy" table,
and I received the info of what I need, the number of column related to a specific ALV Variant.
I used :
ls_variant-report = sy-repid.
ls_variant-variant = p_alvvar. "<<< Select-option field for AVL Variant
ls_variant-log_group = 'L01'.
CALL METHOD lo_grid1->set_table_for_first_display
EXPORTING
i_structure_name = 'MY_STRUCTURE'
is_variant = ls_variant
is_layout = ls_layout
i_save = 'A'
i_default = 'X'
I_BYPASSING_BUFFER = 'X'
CHANGING
it_fieldcatalog = LT_FIELDCATALOG
it_outtab = lt_dummy[].
CALL METHOD lo_grid1->GET_FRONTEND_FIELDCATALOG
IMPORTING
ET_FIELDCATALOG = LT_FIELDCATALOG.
loop at LT_FIELDCATALOG into ls_FIELDCATALOG where no_out = space.
add 1 to LV_NB_COLUMNS.
endloop.
Jo -
Apply ALV variant before export file in background task
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 ?
ThanksSalut 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. -
Help needed on ALV variant with new GUI screen is created by set PF status
Hi Gurus,
I have created a new GUI screen for ALV grid display thru set pf-status, since i need two buttons on application toolbar.
have been passing parameters to alv_grid_display FM for display-*
i_save = 'A'
is_variant = gwa_variant
I have an ALV variant selection paramter on selection screen.
Please guide me with some pointers on how to implement ALV variant selection thru selection screen.
Many Thanks,
MadanHi,
Search default variant for the report
CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
i_save = 'A'
CHANGING
cs_variant = i_variant1
EXCEPTIONS
not_found = 2.
If default variant is found , use it as default.
Else , use the variant LAYOUT1.
IF sy-subrc = 0.
p_var = i_variant1-variant.
ELSE.
p_var = 'LAYOUT1'.
ENDIF.
endform. " SUB_VARIANT_INIT
*& Form SUB_CHECK_PVAR
Once the user has entered variant, check about its existence
FORM SUB_CHECK_PVAR.
If the name of the variable is not blank, check about its existence
if not p_var is initial.
clear i_variant.
i_variant-report = sy-repid.
i_variant-variant = p_var.
CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
EXPORTING
I_SAVE = 'A'
CHANGING
CS_VARIANT = I_VARIANT.
If no such variant found , flash error message
if sy-subrc ne 0 .
message e398(00) with 'No such variant exists'.
else.
If variant exists , use the variant name to populate structure
I_VARIANT1 which will be used for export parameter : IS_VARIANT
in the function module : REUSE_ALV_GRID_DISPLAY
clear i_variant1.
move p_var to i_variant1-variant.
move sy-repid to i_variant1-report.
endif.
else.
clear i_variant.
endif.
ENDFORM. " SUB_CHECK_PVAR
*& Form SUB_VARIANT_F4
Display a list of various variants of the report when the
user presses F4 key in the variant field
form SUB_VARIANT_F4.
i_variant-report = sy-repid.
Utilising the name of the report , this function module will
search for a list of variants and will fetch the selected one into
the parameter field for variants
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
IS_VARIANT = I_VARIANT
I_SAVE = 'A'
I_DISPLAY_VIA_GRID = 'X'
IMPORTING
ES_VARIANT = I_VARIANT1
EXCEPTIONS
NOT_FOUND = 1
PROGRAM_ERROR = 2
OTHERS = 3.
IF SY-SUBRC = 0.
P_VAR = I_VARIANT1-VARIANT.
ENDIF.
endform. " SUB_VARIANT_F4
Thanks
Ashu -
Need to add Message variant field in BD87 selection option
Hi Friends,
We have a requirement to add "Message variant" field in BD87 selction screen. Our technical team is doing analysis from there end. Mean time we came to know that the field can be added through report variant in customiziting. If anyone know how to add the additonal field thorugh customization Please guide us also please pro.Hi Jaheer ,
If you talking Abuot heading in out put screen then use TOP-OF-PAGE
or Else you use "Write:/ " Statement in you program...So that when first line is complete it will go to next line...
What I understand from your Question....
Souman -
Hi Experts,
I need to implement F4 help for ALV table field.
I my scenario, I am using two views. If we click on any record in fist view then it displays the popup window (second view) with relevant record details.
Here one of the columns having fieldnames corresponding values (old values), for correcting old values I have created new value editable column, we can enter new value for old value then we can save it. Till this functionality is ok.
Then I have included OVS help for new value field. Here I need to get f4 help for newvalue field relevant to fieldname.
For example: user clicks on f4 in cell (new value) then if corresponding fieldname is u2018WERKSu2019 then it shows the plant values
Here I can get fieldname, domain name and value table using method set_attribute ().
Same concept I have implemented in ALV using F4IF_FIELD_VALUE_REQUEST. It is working fine
Here I have little bit confusion. Please advise me how to implement in OVS.
Regards,
BBCHi,
you'll have to create a method for the OVS search help (define it in the "OVS component usage" field in the context).
Sample code (should work for WERKS):
method on_ovs .
declare data structures for the fields to be displayed and
for the table columns of the selection list, if necessary
types:
begin of lty_stru_input,
add fields for the display of your search input here
WERKS TYPE WERKS,
end of lty_stru_input.
types:
begin of lty_stru_list,
add fields for the selection list here
WERKS TYPE WERKS_D,
NAME1 type NAME1,
end of lty_stru_list.
data: ls_search_input type lty_stru_input,
lt_select_list type standard table of lty_stru_list,
ls_text type wdr_name_value,
lt_label_texts type wdr_name_value_list,
lt_column_texts type wdr_name_value_list,
lv_window_title type string,
lv_group_header type string,
lv_table_header type string,
lv_werks type werks_d.
field-symbols: <ls_query_params> type lty_stru_input,
<ls_selection> type lty_stru_list.
case ovs_callback_object->phase_indicator.
when if_wd_ovs=>co_phase_0. "configuration phase, may be omitted
in this phase you have the possibility to define the texts,
if you do not want to use the defaults (DDIC-texts)
Set label from Medium Description to something more logical...
ls_text-name = `NAME1`. "must match a field in list structure
ls_text-value = `Plant description`.
insert ls_text into table lt_label_texts.
Set col header from Medium Description to something more logical...
ls_text-name = `NAME1`. "must match a field in list structure
ls_text-value = `Plant description`.
insert ls_text into table lt_column_texts.
lv_window_title = wd_assist->get_text( `003` ).
lv_group_header = wd_assist->get_text( `004` ).
lv_table_header = wd_assist->get_text( `005` ).
ovs_callback_object->set_configuration(
label_texts = lt_label_texts
column_texts = lt_column_texts
group_header = lv_group_header
window_title = lv_window_title
table_header = lv_table_header
col_count = 2
row_count = 20 ).
when if_wd_ovs=>co_phase_1. "set search structure and defaults
In this phase you can set the structure and default values
of the search structure. If this phase is omitted, the search
fields will not be displayed, but the selection table is
displayed directly.
Read values of the original context (not necessary, but you
may set these as the defaults). A reference to the context
element is available in the callback object.
ovs_callback_object->context_element->get_static_attributes(
importing static_attributes = ls_search_input ).
pass the values to the OVS component
ovs_callback_object->set_input_structure(
input = ls_search_input ).
when if_wd_ovs=>co_phase_2.
If phase 1 is implemented, use the field input for the
selection of the table.
If phase 1 is omitted, use values from your own context.
if ovs_callback_object->query_parameters is not bound.
endif.
assign ovs_callback_object->query_parameters->*
to <ls_query_params>.
if not <ls_query_params> is assigned.
TODO exception handling
endif.
call method ovs_callback_object->context_element->get_attribute
exporting
name = 'WERKS'
importing
value = lv_werks.
data: lv_subcat_text type rstxtmd.
select werks
name1
into table lt_select_list
from T001W.
ovs_callback_object->set_output_table( output = lt_select_list ).
when if_wd_ovs=>co_phase_3.
apply result
if ovs_callback_object->selection is not bound.
endif.
assign ovs_callback_object->selection->* to <ls_selection>.
if <ls_selection> is assigned.
ovs_callback_object->context_element->set_attribute(
name = `WERKS`
value = <ls_selection>-werks ).
endif.
endcase.
endmethod. -
HI EXPERTS,
IN ALV OUTPUT FIELD LENTH IS MAX 128?
IN MY REQUIRMENT THE FIELD HAS 500 CHARTERS
Moderator Message: So where is the question? And why type in CAPITAL letters? Do some research before you post a question here. Also, please read the Rules of Engagement of this forum
Edited by: kishan P on Apr 1, 2011 10:10 AMHi,
Linking F4 Help to Fields
For the last section, we will deal with linking F4 help to fields. It is easy. As usual, define, implement and register the event onf4 at proper places in your code. For F4 help, you must register the fields whose F4 request will trigger the onf4 event. For this you must prepare a table of type LVC_T_F4 and register this table using the method register_f4_for_fields. While preparing table you must include a line for each field which will trigger F4 event. For each field in the structure;
Pass the fieldname to FIELDNAME
Set REGISTER to make the field registered,
Set GETBEFORE to provide field content transport before F4 in editable mode
Set CHNGEAFTER to make the data changed after F4 in editable mode.
Preparing table for the fields to be registered to trigger F4 event
DATA: lt_f4 TYPE lvc_t_f4 WITH HEADER LINE .
lt_f4-fieldname = 'PRICE'.
lt_f4-register = 'X' .
lt_f4-getbefore = 'X' .
APPEND lt_f4 .
CALL METHOD gr_alvgrid->register_f4_for_fields
EXPORTING
it_f4 = lt_f4[] .
A sample onf4 method implementation
METHOD handle_on_f1 .
PERFORM f4_help USING e_fieldname es_row_no .
er_event_data->m_event_handled = 'X' .
Again, we set the attribute er_event_data->m_event_handled to prevent further processing of standard F4 help.
Regards,
Ranjit Thakur.
<b>Please Mark The Helpful Answer.</b>
ENDMETHOD . -
ALV Variant Table and Hiding Variants
Hi
Where can I find the table where all ALV variants are stored?
I tried to run a Trace and it brought back LTCX table but there doesn't seem to be any entries in this table?
Also is there a way I can hide variants based on transaction code?check this LTDX,TVARV,VARIS and fm RS_VARIANT_CONTENTS
table VARID shows information about variant creation and date
VARIT shows the variant description and the language used -
ALV flter fields where we can get.
hi friends,
i created a ALV report i placed upload button on the man bar. when we press it upload data using bdc conditions. it is working fine.
but if user filter some data on the alv display using filter button, how can i get data which is showing on the alv display. can i get that data or not.
thanq.
rajesh.kHi,
create a field called BOX in your itab of lenght 1 and type c.
do not display this in the ALV, ( no field cat for this )
but in the layout - box_fieldname = 'BOX'.
Now after the filter ask your user to select the rows by clicking the button which is available in the left side.
so that those filtered and selected rows will be marked as 'X' in the box field in your internal table.
Now you can get all the filtered as well as selected rows.
Regards,
Venkatesh -
Hi Guys.
I've a question. I've created a ALV variant in DEV and now I need transport it to QA.
Is it possible ?
regards.
Javier.Check this out.
http://help.sap.com/saphelp_sm32/helpdata/en/bd/839d37664e4d45e10000009b38f8cf/content.htm
All the way to the bottom on this link.
Regards,
RIch Heilman
Message was edited by:
Rich Heilman -
Hi All,
I have an ALV variant for Prog1. Now I want to copy and use the same variant for Prog2. (Prog2 is a copy of Prog1 with some small changes)
How can I do this?
Thanks & Regards,
SaurabhHi
Try to copy the hits of the table LTDX and change the name of the program
Max -
Switching between ALV variants
Hi Experts
Is there any way to switch between the variants of an ALV without using the std dropdown available in alv header.
I have a requirement to navigate to various views depending on the current ALV variant selected by the user in my application.
Thanks and Regards
KarthickHi Experts
Is there any way to switch between the variants of an ALV without using the std dropdown available in alv header.
I have a requirement to navigate to various views depending on the current ALV variant selected by the user in my application.
Thanks and Regards
Karthick -
Download Alv into excel sheet according to variant fields
Hi All,
I have more than 100 fields in the ALV report, now i want to download the report according to the fields are choosen in the variant. I am getting all the fields in excel sheet but i need some fileds that is selected in the variant.
Thanks in advance.
Rudhiruse your own excel button and program this steps:
1°
* Get the frontend fieldcatalog
CALL METHOD go_grid->get_frontend_fieldcatalog
IMPORTING
et_fieldcatalog = lt_fieldcat.
DELETE lt_fieldcat WHERE no_out EQ 'X'.
2°
*create dynamic table with the frontend fieldcatalog
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = lt_fieldcat
IMPORTING
ep_table = lt_data
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
IF sy-subrc EQ 0.
ASSIGN lt_data->* TO <lt_table>.
ENDIF.
3° Fill the dynamic table
4° export to excel using
CALL FUNCTION 'XXL_SIMPLE_API'
TABLES
col_text = xmplt_v1
data = <lt_table>
online_text = xmplt_o1
print_text = xmplt_p1
EXCEPTIONS
dim_mismatch_data = 1
file_open_error =2
file_write_error = 3
inv_winsys =4
inv_xxl =5
OTHERS = 6.
Check the complete example here -
How to find fields in ALV variant
Hi,
How do we find the fields in ALV layout? I have a layout name. I want to find what are all the fields that are available in the layoutlink:[http://wiki.sdn.sap.com/wiki/display/stage/ToGetFieldDetailsSavedinVariant+Layout]
-
Need to know fields saved in a ALV variant
I have an ALV grid display.the users have ALV layout variants saved.
Is there someway in the program to identify what are all the columns that are part of the layout selected.. Probably there is a standard ALV standard FM or mathod that gives thisMaybe you can try this...<b>LVC_VARIANT_SAVE_LOAD</b>
Greetings,
Blag.
Maybe you are looking for
-
This might turn into an open letter to RIM, so please bear with me. I have been a BlackBerry user for 4 years now and, as a non-enterprise user, I am running into too many limitations to e-mail functionality. 1. Truncated Email This is the first aspe
-
When I answer email from arboristsite. com I get a search engine pop-up. Why?
When I go to Arboristsite.com and click on one of the forums I get a search engine pop up. It doesn't happen on Opera or Internet Explorer. I don't know how to get rid of the pop up. This pop up also shows up when I get an email notice from arborists
-
Know Exceptions thrown in Java Finalizer thread...
Hello, I have one question regarding java finalizer thread. How can i know about exceptions thrown by finalize method which has been called from the finalizer thread of JVM?. Any help would be appreciated? Thanks and Regards
-
Hi there, Our site is running on Weblogis server 5.0. We are using EJBs, JSPs. We have several JSP custom tags. but, one of those is raising an exception quite often: Tue Jul 25 21:37:19 EDT 2000:<E> <ServletCo
-
Form Field Error when similar names
In Adobe Acrobat X Pro, I receive the following error when I try to change the name of a text field from Company.BS.Condition1.Date to Company.BS.Condition.Date: "A field of a different type already uses this name. Please choose a new name for the fi