cancel
Showing results for 
Search instead for 
Did you mean: 

Button in ALV Coloumn

Former Member
0 Kudos

Hello Experts,

I am having a requirement to show buttons as a coloumn in ALV.

I dont know how to achieve it. Could you Please suggest and help?

Thanks in Advance.....

Best Regards,

Sahil

Accepted Solutions (0)

Answers (5)

Answers (5)

cuky
Participant
0 Kudos

Hello,

I followed these instructions but could not get it to work. My SALV table shows me just the regular columns, with the desired columns as simple text instead of buttons. I defined all of the objects and copied the logic and I don't know what else can I do to display the buttons instead of the columns' cells.

Any help would be much appreciated.

Thank you!

Former Member
0 Kudos

Hi,

see this example

SALV_WD_TEST_DYN1.

go for the component controller fillalv1().in this they have created an image in the column.

instead of image replace the code related to button,

here declare a variable lr_button type ref to CL_SALV_WD_UIE_BUTTON

and use,

arjun_thakur
Active Contributor
0 Kudos

Hi Sahil,

Plz refer to this [article|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/bd28494a-0801-0010-45a3-fc359d82d3e8] and have a look at this [thread|] as well.

I hope it helps.

Regards

Arjun

former_member402443
Contributor
0 Kudos

Hi Sahil,

The logic for creating a button as a columns in alv is as follow:

  • Display button in column carrid

DATA: lr_button TYPE REF TO cl_salv_wd_uie_button.

lr_column = l_value->if_salv_wd_column_settings~get_column( 'CARRID' ).

CREATE OBJECT lr_button.

lr_button->set_text_fieldname( 'CARRID' ).

lr_column->set_cell_editor( lr_button ).

Regards

Manoj Kumar

uday_gubbala2
Active Contributor
0 Kudos

Hi Sahil,

It is possible to set all sorts of UI elements inside the cells of a column. Those elements are called cell editors. I will explain as to how you can create a button element and set its tooltip (optional not mandatory for the button) . Then set the button as the cell editor of the button. First you need to obtain the references of all the columns into an internal table and need to modify the cell editors while looping through them.

DATA: lr_salv_wd_table TYPE REF TO iwci_salv_wd_table,
          r_table TYPE REF TO CL_SALV_WD_CONFIG_TABLE.

" Get reference to ALV component interface 
lr_salv_wd_table = wd_this->wd_cpifc_alvmain( ). 

" Get ConfigurationModel from ALV Component
wd_this->r_table = lr_salv_wd_table->get_model( ).

DATA: lr_column_settings TYPE REF TO if_salv_wd_column_settings,
      lr_col_header TYPE REF TO cl_salv_wd_column_header. 

lr_column_settings ?= wd_this->r_table. 

" Get references to all columns in an internal table

DATA: lt_columns TYPE salv_wd_t_column_ref. 

lt_columns = lr_column_settings->get_columns( ).

" Loop through the column references and set the desired cells as buttons

LOOP AT lt_columns INTO ls_column.
CASE ls_column-id.
WHEN 'DBC_ICO'.
    DATA: lr_button TYPE REF TO cl_salv_wd_uie_button. 
    CREATE OBJECT lr_button.

" set width to 1 to make column as small as possible
" the width is always adapted to minimum width of celleditor
 ls_column-r_column->set_width( '1' ).

" image source is in the value of the cell 

lr_button->set_image_source_fieldname( ls_column-id ).

" retrieve translatable text for tooltip

ls_tooltip = cl_wd_utilities=>get_otr_text_by_alias( 'NNL1/DBC' ). 

CALL METHOD lr_button->set_tooltip EXPORTING value = ls_tooltip. 

CALL METHOD ls_column-r_column->set_cell_editor EXPORTING value = lr_button.

Regards,

Uday