03-28-2006 6:26 AM - edited 02-04-2024 4:14 AM
Hi
I need to make an ALV Editable and save/Update data to a table. Can this is be done ?
Sample source code would be helpful.
03-28-2006 6:44 AM
Hi,
R u using FM or.............
If u r using FM look at my example.....
data: LC_GLAY TYPE LVC_S_GLAY.
LC_GLAY-EDT_CLL_CB = 'X'.<<<<<------
gt_layout-zebra = 'X'.
gt_layout-detail_popup = 'X'.
gt_layout-colwidth_optimize = 'X'.
call function 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = i_repid
i_callback_user_command = 'USER_COMMAND1'
it_fieldcat = header
is_layout = gt_layout
i_callback_top_of_page = 'TOP-OF-PAGE1'
i_grid_title = text-h17
it_sort = gt_sort[]
i_default = 'X'
i_save = 'U'
is_variant = gt_variant
it_events = gt_events
I_GRID_SETTINGS = LC_GLAY<<<<<<------
TABLES
t_outtab = itab.
clear itab.
----
Form USER_COMMAND1
----
FORM USER_COMMAND1 USING u_ucomm LIKE sy-ucomm
us_selfield TYPE slis_selfield."#EC CALLED
case u_ucomm.
when '&DATA_SAVE'.<<<<<<<<----
This will come after the data was EDITTED and when SAVE was clicked by user in output scren.
Here now in the final internal table(ITAB) you can find the data changed in EDIT mode.
After this you can do manipulation what ever you want.
Thanks.
If this helps you reward with points.
03-28-2006 6:32 AM
Murali,
Look at these sample programs in the SAP system.
BCALV_EDIT_01
BCALV_EDIT_02
BCALV_EDIT_03
BCALV_EDIT_04
BCALV_EDIT_05
BCALV_EDIT_06
BCALV_EDIT_07
BCALV_EDIT_08
BCALV_FULLSCREEN_GRID_EDIT
BCALV_GRID_EDIT
Regards,
Ravi
Note : Please mark the helpful answers
03-28-2006 6:36 AM
Hi Murali,
To make fields of ALV editable you can set the EDIT field of the fieldcatalog to 'X'.
fieldcatalog-edit = 'X'.
Then to save the changed data back, the changes would be reflected in your internal table that you had used to display. Use this to modify your database table.
Are you using ALV using classes?
03-28-2006 6:39 AM
Hi Murali,
just set in fieldcat ..
To make a column editable, it will be sufficient to set the field EDIT in the field catalog..
the change that you make are already stored in the internal table itself..
you can just make use of that to store it or save it back into the TABLE..
but before that you'll have to handle ..
<b> handle_data_changed FOR EVENT data_changed OF cl_gui_alv_grid IMPORTING er_data_changed</b>..
this event captures the data into the itab..
and it can be save d or updated into the TABLE..
regards
satesh
03-28-2006 6:41 AM
Hai Murali,
check out these demo editable alv grids. they all have single row select.
BCALV_GRID_EDIT
BCALV_TEST_GRID_EDITABLE
Here is the sample code...
method SET_READY_FOR_INPUT_INTERNAL
data: l_mode type i.
if is_ready_for_input( ) eq 1 and
( m_cl_variant->ms_layout-sel_mode eq 'B' or
m_cl_variant->ms_layout-sel_mode eq 'C' ).
l_mode = 0.
else.
case m_cl_variant->ms_layout-sel_mode.
when 'A'. "Row/Col-Select
l_mode = 0.
when 'B'. "Single Select Listbox
l_mode = 1.
when 'C'. "Multi Select Listbox
l_mode = 2.
when 'D'. "Full Select
l_mode = 3.
when others.
if is_ready_for_input( ) eq 0.
l_mode = 1.
else.
l_mode = 0.
endif.
endcase.
endif.
call method me->set_selection_mode_base
exporting
mode = l_mode.
Here is a helpful link..
regards,
srikanth.
reward points if helpful...
03-28-2006 6:44 AM
Hi,
R u using FM or.............
If u r using FM look at my example.....
data: LC_GLAY TYPE LVC_S_GLAY.
LC_GLAY-EDT_CLL_CB = 'X'.<<<<<------
gt_layout-zebra = 'X'.
gt_layout-detail_popup = 'X'.
gt_layout-colwidth_optimize = 'X'.
call function 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = i_repid
i_callback_user_command = 'USER_COMMAND1'
it_fieldcat = header
is_layout = gt_layout
i_callback_top_of_page = 'TOP-OF-PAGE1'
i_grid_title = text-h17
it_sort = gt_sort[]
i_default = 'X'
i_save = 'U'
is_variant = gt_variant
it_events = gt_events
I_GRID_SETTINGS = LC_GLAY<<<<<<------
TABLES
t_outtab = itab.
clear itab.
----
Form USER_COMMAND1
----
FORM USER_COMMAND1 USING u_ucomm LIKE sy-ucomm
us_selfield TYPE slis_selfield."#EC CALLED
case u_ucomm.
when '&DATA_SAVE'.<<<<<<<<----
This will come after the data was EDITTED and when SAVE was clicked by user in output scren.
Here now in the final internal table(ITAB) you can find the data changed in EDIT mode.
After this you can do manipulation what ever you want.
Thanks.
If this helps you reward with points.
03-28-2006 6:51 AM
Hi
Can you give me some more idea about your problem.In which situation you want to change the ALV.
I hope i can give you some more inputs after that.
Thanks
Mrutyunjaya Tripathy
03-28-2006 6:53 AM
Hi
Thanks for the input. I am using 'REUSE_ALV_GRID_DISPLAY'. I am not using classes and Objects. I shall start now with your inputs. Thanks a Lot.