cancel
Showing results for 
Search instead for 
Did you mean: 

Checkboxes with alv table

Former Member
0 Kudos

Hi,

in my component I am displaying a table. I need to add functionality to this tableview, so that enduser can tick one ore more rows, and then let the method record the ticked row(s).

Could anyone please help, with a step to step guide, from the tablecontex tlevel and up ?

Thank you.

Regards

Arne Jakob

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

You can create a check box in ALV using the following code.

First create an attribute of type boolean for the checkbox column and bind it and use the following code to populate ALV with checkbox

METHOD WDDOINIT.
  DATA:
    lr_alv_usage       TYPE REF TO if_wd_component_usage,
    lr_if_controller   TYPE REF TO iwci_salv_wd_table,
    lr_config          TYPE REF TO cl_salv_wd_config_table,
    lr_column_settings TYPE REF TO if_salv_wd_column_settings,
    lt_columns         TYPE        salv_wd_t_column_ref,
    lr_link            TYPE REF TO cl_salv_wd_uie_link_to_action,
    lr_checkbox        TYPE REF TO cl_salv_wd_uie_checkbox,
    lr_image           type ref to cl_salv_wd_uie_image.
  FIELD-SYMBOLS
    <fs_column> LIKE LINE OF lt_columns.

* Instantiate the ALV Component
  lr_alv_usage = wd_this->wd_cpuse_cmp_alv( ).
  IF lr_alv_usage->has_active_component( ) IS INITIAL.
    lr_alv_usage->create_component( ).
  ENDIF.

* Get reference to model
  lr_if_controller = wd_this->wd_cpifc_cmp_alv( ).
  lr_config        = lr_if_controller->get_model( ).

* 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 'CHECKBOX'.
        CREATE OBJECT lr_checkbox
          EXPORTING
            checked_fieldname = <fs_column>-id.
        <fs_column>-r_column->set_cell_editor( lr_checkbox ).
        FREE lr_checkbox.
      WHEN 'OTHERS'.
     ENDCASE.
  ENDLOOP.
ENDMETHOD.

"Now implement the OnCLick event . This event will be triggered whenever a chekcbox is ticked.
In this method you can fill your internal table with rows that are selected using the checkbox

Former Member
0 Kudos

hi,

To create Checkbox inside an AlV Column , refer this blog :

https://wiki.sdn.sap.com/wiki/display/Snippets/Web%20Dynpro%20ABAP%20-%20Using%20UI%20elements%20in%...

To create an event for Checkbox created refer this thread:

SAP Online help on Various Events of ALV:

http://help.sap.com/saphelp_nw70ehp1/helpdata/en/45/12093591152464e10000000a1553f7/frameset.htm