cancel
Showing results for 
Search instead for 
Did you mean: 

How to Display icon in an ALV?

Former Member
0 Kudos

Hello Experts,

Could you please help me on how to display a icon in any ALV.

Thanking You in Advance,

Tamanna k

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Can you be more specific...You want an icon in a ALV column/Cell or as a header....

Regards,

Lekha.

Former Member
0 Kudos

hello Lekha,,

I want it to be in one of the columns of the ALV.

Regards,

Tamanna.

Former Member
uday_gubbala2
Active Contributor
0 Kudos

Hi Tamanna,

You would have to basically change the cell editor of the column in which you want to display the icon into an Image. (CL_SALV_WD_UIE_IMAGE) You then specify the source of the image using either SET_SOURCE or SET_SOURCE_FIELDNAME. The process for doing this explained in detail in the link which Lekha has already passed you. (David Pietroniro's link)

If you however intend to set an icon & text within the same cell of the ALV then you need to change the cell editor of the desired ALV column into a Caption. (cl_salv_wd_uie_caption) The Caption has both a "image source" & "text" property. So you can just change the cell editor to a Caption & set these 2 properties to display both an icon & text within the same cell. Below is a code snippet explaining the same:

Regards,

Uday

METHOD build_alv .
  DATA: l_ref_cmp_usage TYPE REF TO if_wd_component_usage,
        lr_column_settings TYPE REF TO if_salv_wd_column_settings,
        lt_columns         TYPE        salv_wd_t_column_ref.
  DATA: lr_table_settings TYPE REF TO if_salv_wd_table_settings.


"*** Instantiate the used ALV Component
  l_ref_cmp_usage =   wd_this->wd_cpuse_my_alv( ).

  IF l_ref_cmp_usage->has_active_component( ) IS INITIAL.
    l_ref_cmp_usage->create_component( ).
  ENDIF.

"*** Get reference to the model
  DATA: l_ref_interfacecontroller TYPE REF TO iwci_salv_wd_table,
        lr_config TYPE REF TO cl_salv_wd_config_table,
        lr_caption        TYPE REF TO cl_salv_wd_uie_caption.


  FIELD-SYMBOLS <fs_column> LIKE LINE OF lt_columns.

  l_ref_interfacecontroller =   wd_this->wd_cpifc_my_alv( ).

  lr_config = l_ref_interfacecontroller->get_model( ).

"*** Trying to set entire ALV table to editable
  lr_table_settings ?= lr_config.
  lr_table_settings->set_read_only( abap_false ).


"**** Set the UI elements.
  lr_column_settings ?= lr_config.
  lt_columns = lr_column_settings->get_columns( ).

  LOOP AT lt_columns ASSIGNING <fs_column>.
    CASE <fs_column>-id.
      WHEN 'CHECK'.
         CREATE OBJECT lr_caption.
         lr_caption->set_image_source( value = '~Pictogram/3People' ).
         lr_caption->SET_TEXT( value = 'My Text!' ).

        <fs_column>-r_column->set_cell_editor( lr_caption ).
    ENDCASE.
  ENDLOOP.
ENDMETHOD.                   ""BUILD_ALV

Answers (1)

Answers (1)

Former Member
0 Kudos

you can make one of the column in the ALV as the image type and assign the icon values (constants) to it.

bind the source f the image property to string attribute and set the value something like bnelow

lo_nd_tbl_as_led->set_attribute(

value = 'ICON_LED_RED'

name = 'INVALID' ).

this will be helping to create a green led icon