Skip to Content
author's profile photo Former Member
Former Member

Button in ALV Coloumn

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Posted on Feb 13, 2009 at 05:48 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Feb 13, 2009 at 05:51 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Feb 13, 2009 at 06:33 AM

    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|double-click-functionality-on-alv] as well.

    I hope it helps.

    Regards

    Arjun

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 16, 2009 at 05:05 AM

    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,

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 14, 2016 at 03:15 PM

    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!

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.