01-22-2008 6:29 PM
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
01-22-2008 7:05 PM
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
01-22-2008 7:48 PM
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
01-23-2008 5:57 AM
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.