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

ALV grid

Former Member
0 Likes
949

Hi,

I am using the following code to display the ALV list,I get a column for selecting rows , the issue here is that selecting multiple rows is not posssible without keeping the "CTRL" key pressed down, is there any way i can do the multiple selections part without keeping the "CTRL" key pressed down?

in other words is there any other way writing the statement

*... §7.1 set selection mode
lr_selections->set_selection_mode( if_salv_c_selection_mode=>row_column ).




CODE
form display_alv.


try.
cl_salv_table=>factory(
importing
r_salv_table = gr_table
changing
t_table = t_outtab ).
catch cx_salv_msg. "#EC NO_HANDLER
endtry.

gr_table->set_screen_status(
pfstatus = 'STANDARD_ALV'
report = sy-repid
set_functions = gr_table->c_functions_all ).


*... set the columns technical
data: lr_columns type ref to cl_salv_columns.

lr_columns = gr_table->get_columns( ).
lr_columns->set_optimize( abap_true ).

  • perform set_columns_technical using lr_columns.

*... §6 register to the events of cl_salv_table

data: lr_events type ref to cl_salv_events_table.

lr_events = gr_table->get_event( ).

create object gr_events.

*... §6.1 register to the event USER_COMMAND

set handler gr_events->on_user_command for lr_events.

*... §7 selections

data: lr_selections type ref to cl_salv_selections,

lt_rows type salv_t_row,

lt_column type salv_t_column,

ls_cell type salv_s_cell.

lr_selections = gr_table->get_selections( ).

*... §7.1 set selection mode

lr_selections->set_selection_mode( if_salv_c_selection_mode=>row_column ).

*... §4 display the table

gr_table->display( ).

endform.

Hi,

I am using the following code to display the ALV list,I get a column for selecting rows , the issue here is that selecting multiple rows is not posssible without keeping the "CTRL" key pressed down, is there any way i can do the multiple selections part without keeping the "CTRL" key pressed down?

in other words is there any other way writing the statement

*... §7.1 set selection mode
lr_selections->set_selection_mode( if_salv_c_selection_mode=>row_column ).




CODE
form display_alv.


try.
cl_salv_table=>factory(
importing
r_salv_table = gr_table
changing
t_table = t_outtab ).
catch cx_salv_msg. "#EC NO_HANDLER
endtry.

gr_table->set_screen_status(
pfstatus = 'STANDARD_ALV'
report = sy-repid
set_functions = gr_table->c_functions_all ).


*... set the columns technical
data: lr_columns type ref to cl_salv_columns.

lr_columns = gr_table->get_columns( ).
lr_columns->set_optimize( abap_true ).

  • perform set_columns_technical using lr_columns.

*... §6 register to the events of cl_salv_table

data: lr_events type ref to cl_salv_events_table.

lr_events = gr_table->get_event( ).

create object gr_events.

*... §6.1 register to the event USER_COMMAND

set handler gr_events->on_user_command for lr_events.

*... §7 selections

data: lr_selections type ref to cl_salv_selections,

lt_rows type salv_t_row,

lt_column type salv_t_column,

ls_cell type salv_s_cell.

lr_selections = gr_table->get_selections( ).

*... §7.1 set selection mode

lr_selections->set_selection_mode( if_salv_c_selection_mode=>row_column ).

*... §4 display the table

gr_table->display( ).

endform.

6 REPLIES 6
Read only

amit_khare
Active Contributor
0 Likes
901

Hi,

Add a field in your internal table of type C and populate it in Layout of type BOX.

Regards,

Amit

Read only

Former Member
0 Likes
901

Hi,

Thanks for responding! but i already have the column, i need to select multiple rows without keeping the CTRL key pressed.

Regards

Narendiran Rathinavelu

Read only

0 Likes
901

Hi Naren,

If u need to select multiple rows then u have press the CNTRL kay else its not possible to select multiple rows..

Read only

0 Likes
901

Hi Narendiran.

If you don't want to use control key,

as you have box field on left,

You can use tab key to come to that box and than press spacebar , the box will be marked.

Regards

Kaushal N. Shah .

Read only

Former Member
0 Likes
901

Hi

Selection of multiple rows using grid that too without CNTL button is not possible in Grid. My suggestion is use ALV LIST display for this or just print some message in Header that press CNTL button and select for multile selections.

Read only

Former Member
0 Likes
901

Please check this example

REPORT zkb_test.

TYPES: BEGIN OF t_table,

status TYPE c,

sdate TYPE sy-datum,

emptype(20) TYPE c,

celltab TYPE lvc_t_styl,

END OF t_table.

DATA: o_grid TYPE REF TO cl_gui_alv_grid,

o_container TYPE REF TO cl_gui_custom_container.

DATA: i_table TYPE TABLE OF t_table.

DATA: w_table TYPE t_table.

DATA: i_fcat TYPE lvc_t_fcat,

i_layo TYPE lvc_s_layo.

START-OF-SELECTION.

PERFORM populate_data.

PERFORM build_field_catalogue.

END-OF-SELECTION.

CALL SCREEN 9000.

&----


*& Form populate_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM populate_data .

CLEAR w_table.

w_table-status = 'X'.

w_table-sdate = '20061025'.

w_table-emptype = 'Active'.

APPEND w_table TO i_table.

CLEAR w_table.

w_table-status = ' '.

w_table-sdate = '20061023'.

w_table-emptype = 'Active'.

APPEND w_table TO i_table.

CLEAR w_table.

w_table-status = ' '.

w_table-sdate = '20061005'.

w_table-emptype = 'With-Drawn'.

APPEND w_table TO i_table.

CLEAR w_table.

w_table-status = 'X'.

w_table-sdate = '20061025'.

w_table-emptype = 'Active'.

APPEND w_table TO i_table.

ENDFORM. " populate_data

&----


*& Form build_field_catalogue

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM build_field_catalogue .

DATA: ls_fcat TYPE lvc_s_fcat.

CLEAR ls_fcat.

ls_fcat-fieldname = 'STATUS'. "Fieldname

ls_fcat-inttype = 'CHAR'. "Data type

ls_fcat-outputlen = '1'. "Column width

ls_fcat-coltext = 'Status'. "Column Header

ls_fcat-seltext = 'Status'. "Column Desc

ls_fcat-checkbox = 'X'. "Set as Check Box

ls_fcat-edit = 'X'. "Set editable

APPEND ls_fcat TO i_fcat.

CLEAR ls_fcat.

ls_fcat-fieldname = 'SDATE'. "Fieldname

ls_fcat-inttype = 'DATS'. "Data type

ls_fcat-outputlen = '8'. "Column width

ls_fcat-coltext = 'Date'. "Column Header

ls_fcat-seltext = 'Date'. "Column Desc

ls_fcat-edit = 'X'. "Set editable

APPEND ls_fcat TO i_fcat.

CLEAR ls_fcat.

ls_fcat-fieldname = 'EMPTYPE'. "Fieldname

ls_fcat-inttype = 'CHAR'. "Data type

ls_fcat-outputlen = '20'. "Column width

ls_fcat-coltext = 'Emp Type'. "Column Header

ls_fcat-seltext = 'Emp Type'. "Column Desc

ls_fcat-edit = 'X'. "Set editable

APPEND ls_fcat TO i_fcat.

ENDFORM. " build_field_catalogue

&----


*& Module status_9000 OUTPUT

&----


  • text

----


MODULE status_9000 OUTPUT.

SET PF-STATUS '9000'.

ENDMODULE. " status_9000 OUTPUT

&----


*& Module user_command_9000 INPUT

&----


  • text

----


MODULE user_command_9000 INPUT.

CASE sy-ucomm .

WHEN 'BACK' OR 'EXIT'.

SET SCREEN 0.

LEAVE SCREEN.

ENDCASE.

ENDMODULE. " user_command_9000 INPUT

&----


*& Module init_9000 OUTPUT

&----


  • text

----


MODULE init_9000 OUTPUT.

IF o_container IS INITIAL.

IF cl_gui_alv_grid=>offline( ) IS INITIAL.

  • Create a custom container control for ALV Control

CREATE OBJECT o_container

EXPORTING

container_name = 'CUSTOM_CONTROL'.

  • Create a ALV Control

CREATE OBJECT o_grid

EXPORTING i_parent = o_container.

  • Layout Defaults

i_layo-no_rowmark = 'X'.

i_layo-cwidth_opt = 'X'.

  • Display ALV Grid

CALL METHOD o_grid->set_table_for_first_display

EXPORTING

i_save = 'A'

i_default = 'X'

is_layout = i_layo

CHANGING

it_outtab = i_table

it_fieldcatalog = i_fcat.

ENDIF.

ENDIF.

ENDMODULE. " init_9000 OUTPUT

Regards

Kathirvel