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

Selection Column in SALV

Former Member
0 Likes
7,213

How do we create selection column like those in a table control? I'm using OO.

1 ACCEPTED SOLUTION
Read only

Former Member
3,443

The selection column is controlled via a method set_selection_mode in object CL_SALV_SELECTIONS.

it takes values

No selection NONE 0

Single selection SINGLE 1

Multiple selection MULTIPLE 2

Cell selection CELL 3

Row- and column selection ROW_COLUMN 4

using value 1 or 2 will cause the alv to create a selection column.

if you have an alv object created

alv_object type ref to cl_salv_table,

then you need code along the lines


data: gr_selections type ref to cl_salv_selections.

  gr_selections = alv_object->get_selections( ).
  gr_selections->set_selection_mode( 1 ). "Single row selection

7 REPLIES 7
Read only

Former Member
0 Likes
3,443

This message was moderated.

Read only

Former Member
3,444

The selection column is controlled via a method set_selection_mode in object CL_SALV_SELECTIONS.

it takes values

No selection NONE 0

Single selection SINGLE 1

Multiple selection MULTIPLE 2

Cell selection CELL 3

Row- and column selection ROW_COLUMN 4

using value 1 or 2 will cause the alv to create a selection column.

if you have an alv object created

alv_object type ref to cl_salv_table,

then you need code along the lines


data: gr_selections type ref to cl_salv_selections.

  gr_selections = alv_object->get_selections( ).
  gr_selections->set_selection_mode( 1 ). "Single row selection

Read only

0 Likes
3,443

Nice ,Thank you for your answer.

Read only

Former Member
0 Likes
3,443

Hi,

you can make use of CHECKBOX field of structure LVC_S_FCAT, so that Selection will come for every row of the ALV.

& to capture the event when every row is selected use method get_selected_rows of cl_gui_alv_grid

Regards

Abhii...

Read only

0 Likes
3,443

Hi Abhii ,

FYI: There is no fieldcat accessible in SALV. Please search (read?) before answer, thank you.

Regards,

Clemens

Read only

Former Member
0 Likes
3,443

I tried cl_salv_selections as below but I still do not see the selection column.


data:  zref_var type ref to cl_salv_table,
          zref_fun type ref to cl_salv_functions,
          zrv_cols type ref to cl_salv_columns_table,
          zref_col type ref to cl_salv_column_table.
data: gr_selections type ref to cl_salv_selections.

  TRY.

      CALL METHOD cl_salv_table=>factory
        IMPORTING
          r_salv_table = zref_var
        CHANGING
          t_table      = ztb_alv1.

    CATCH cx_salv_data_error cx_salv_not_found.
  ENDTRY.

data: event_handler type ref to lcl_handle_events.

  zrv_cols = zref_var->get_columns( ).
  zrv_cols->set_exception_column( value = 'LIGHT' ).
* change column name
  TRY.
      zref_col ?= zrv_cols->get_column( 'MATNR' ).
      zref_col->set_long_text( 'Material Number' ).
      zref_col->set_medium_text( 'Material No' ).
      zref_col->set_short_text( 'Material' ).
    CATCH cx_salv_not_found.
  ENDTRY.

* Set up selections.
  gr_selections = zref_var->get_selections( ).
  gr_selections->set_selection_mode( 2 ). 

* display alv
  CALL METHOD zref_var->display.

Read only

3,443

Sorry wrong info, value of 3 will create the selection column.

gr_selections->set_selection_mode( 3 ).