‎2007 Jan 23 3:27 PM
Hi,
as described in the subject of this post I have a problem with the method add_function of class cl_salv_functions_list. My intend was to add several buttons in the toolbar of the ALV grid. Adding of these buttons is functional but there is no icon display although I defined the right value. Maybe there is a mistake in calling the method. Please see the attached code.
Prerequisites:
<b>eg. l_icon1 = "ICON_REFRESH" --> or should I use another value???</b>
data: lr_columns type ref to cl_salv_columns_table,
lr_column type ref to cl_salv_column_table,
lr_functions type ref to cl_salv_functions_list,
lr_layout type ref to cl_salv_layout,
ls_key type salv_s_layout_key,
selection type ref to cl_salv_selections,
l_icon1 type string,
l_icon2 type string,
l_icon3 type string,
l_icon4 type string,
e_text type string,
l_oref type ref to cx_root.
try.
l_icon1 = text-ic1.
l_icon2 = text-ic2.
l_icon3 = text-ic3.
ls_key-report = sy-cprog.
lr_columns = r_process_alv->get_columns( ).
lr_functions = r_process_alv->get_functions( ).
lr_layout = r_process_alv->get_layout( ).
lr_functions->set_all( value = if_salv_c_bool_sap=>true ).
try.
lr_functions->add_function(
name = 'SAPDET'
icon = l_icon1
text = 'Details'
tooltip =' Details'
position = if_salv_c_function_position=>left_of_salv_functions
).
lr_functions->add_function(
name = 'APPEND'
icon = l_icon2
tooltip = 'ADD'
position = if_salv_c_function_position=>left_of_salv_functions
).
lr_functions->add_function(
name = 'DELETE'
icon = l_icon3
text = 'Del'
tooltip = 'Session löschen'
position = if_salv_c_function_position=>left_of_salv_functions
).
lr_functions->add_function(
name = 'REFRESH'
icon = l_icon4
text = 'Refresh'
tooltip = 'Refresh'
position = if_salv_c_function_position=>left_of_salv_functions
).
catch cx_salv_wrong_call cx_salv_existing into l_oref.
e_text = l_oref->get_text( ).
message e_text type 'E'.
endtry.
Thanks in advance.
Regards
Maik.
‎2007 Jan 23 11:24 PM
Hello Maik
Rich is right. Since release 6.20 we should use
TYPE-POOLS: icon. " instead of include <icon>.In sample report <b>SALV_DEMO_TREE_FUNCTIONS</b> they use the "cryptic" version of the icons which is not preferable.
try.
l_text1 = text-b01.
l_text2 = text-b02.
lr_functions->add_function(
name = 'MYFUNCTION'
icon = '@DF@'
text = l_text1
tooltip = l_text2
position = if_salv_c_function_position=>right_of_salv_functions ).
catch cx_salv_wrong_call cx_salv_existing.
endtry.Regards
Uwe
‎2007 Jan 23 3:34 PM
‎2007 Jan 23 3:47 PM
The examples, assign the values like so............
data: l_icon type string.
l_icon = icon_green_light. "<-- Icon from type-pool.
try.
lr_functions->add_function(
name = 'MYFUNCTION'
icon = l_icon
text = l_text
tooltip = l_text
position = if_salv_c_function_position=>right_of_salv_functions ).
catch cx_salv_existing cx_salv_wrong_call.
endtry.Try this instead of using text elements.
Regards,
Rich Heilman
‎2007 Jan 23 11:24 PM
Hello Maik
Rich is right. Since release 6.20 we should use
TYPE-POOLS: icon. " instead of include <icon>.In sample report <b>SALV_DEMO_TREE_FUNCTIONS</b> they use the "cryptic" version of the icons which is not preferable.
try.
l_text1 = text-b01.
l_text2 = text-b02.
lr_functions->add_function(
name = 'MYFUNCTION'
icon = '@DF@'
text = l_text1
tooltip = l_text2
position = if_salv_c_function_position=>right_of_salv_functions ).
catch cx_salv_wrong_call cx_salv_existing.
endtry.Regards
Uwe
‎2007 Jan 24 9:32 AM
‎2010 Aug 13 1:37 PM
Hi Maik,
I need to add the Print Preview button. which icon do in need to use???
Thanks,
Ziad
Edited by: ziad khan on Aug 13, 2010 6:09 PM