Application Development 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: 

ALV using chekbox and icon

Former Member
0 Kudos

1) Needs to create two icons for a row in ALV.

With One Icon, she should be able to Edit a ROW. Other icon should support save option and should save the changes in the database table.

How can we do this????

2) Needs to create a checkbox by creating a Field in the database table.

Each row in the table will have a checkbox in ALV.

If a checkbox is selected , that particular row should be selected in the ALV

Regards,

Rajkumar

3 REPLIES 3

Former Member
0 Kudos

Rajkumar,

Check the following code

Types: begin of lt_io.

include structure mara. " Your Structure

Types: style_table type lvc_t_style.

Types: end of lt_io.

data: lt_io type table of lt_io,

ls_layout type lvc_s_layo,

lt_fcat type lvc_t_fcat,

lo_grid type ref to cl_gui_alv_grid.

field-symbols: <io> type lt_io,

<fcat> type lvc_s_fcat.

... fill your output table ....

ls_layout-stylefname = 'STYLE_TABLE'.

loop at lt_io assigning <io>.

PERFORM set_style USING 'CHECKBOX' "Your Filename

CHANGING <io>.

endloop.

... Fill Your Field Catalog lt_fcat

read table lt_fcat assigning <fcat>

where fieldname = 'CHECKBOX'.

<fcat>-checkbox = 'X'.

...

create grid control lo_grid.

...

CALL METHOD lo_grid->set_table_for_first_display

EXPORTING

is_layout = ls_layout

CHANGING

it_fieldcatalog = lt_fcat

it_outtab = lt_io[].

...

FORM set_button_to_line

USING iv_fieldname TYPE lvc_fname

CHANGING cs_io TYPE io.

DATA: ls_style TYPE lvc_s_styl,

lt_style TYPE lvc_t_styl.

ls_style-fieldname = iv_fieldname.

if cs_io-checkbox = ' '.

ls_style-style = cl_gui_alv_grid=>mc_style_enabled.

else.

ls_style-style = cl_gui_alv_grid=>mc_style_disabled.

endif.

ls_style-maxlen = 2.

INSERT ls_style INTO TABLE io-style_table.

ENDFORM. "set_icon_to_status_line

[/code].

Vinodh

uwe_schieferstein
Active Contributor
0 Kudos

Hello

Assuming that you are using OO-based ALV lists then it is nonsense to define a checkbox column. Instead simply set LVC_S_LAYO-SEL_MODE = 'A' in the layout resulting in an additional "mark column" at the left border of the ALV.

To retrieve the selected rows simply call go_grid->get_selected_rows( ).

Regards,

Uwe

vishal_sharda2
Participant
0 Kudos

Hi,

Regarding your second query, do following:

instead of creating a checkbox field in the database table, create a field name 'CHKBOX type c' in the internal table.

Then when you create a field catalog, use:

<fieldcatalog>-fieldname = 'CHKBOX'.

<fieldcatalog>-checkbox = 'X'.

append <fieldcatalog>.

This should solve your problem.

Reward points if helpful.

Regards,

Vishal.