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

Method add_function does not display icon in toolbar

Former Member
0 Likes
5,300

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.

1 ACCEPTED SOLUTION
Read only

uwe_schieferstein
Active Contributor
0 Likes
2,485

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

5 REPLIES 5
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
2,485

Sorry, I mis-read your question, you could use the value or you could use the name from the type-pools.

Regards,

Rich Heilman

Read only

2,485

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

Read only

uwe_schieferstein
Active Contributor
0 Likes
2,486

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

Read only

Former Member
0 Likes
2,485

Thank you very much for your help. Now it works...

Read only

0 Likes
2,485

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