04-14-2005 3:35 PM
hi experts,
i have a editable alv report how to update the changed data on the grid to database table when i click save.
can anybody tell me how to do this if possible with example.
thanks in advance.
regards,
venu
04-14-2005 5:31 PM
Are you using a field-symbol to load the data to the grid? If you are, the changes you make in the grid will also be changed in the field-symbol. You might need to use one of the refresh methods or use check_changed_data to refresh the data into the field-symbol. I used a field-symbol, and then used check_changed_data before trying to save the data. When I did this, the field symbol always had the changed data in it.
Brian
04-14-2005 4:11 PM
Hi Venu,
look in SE38 for BCALV_EDIT*
e.g.: BCALV_EDIT_04
regards Andreas
04-14-2005 4:30 PM
Hi Andreas,
thanks for reply.
but the example programmme is not having complete information about updating of the database table from editable alv grid using oo model.
regards,
venu.
04-14-2005 6:01 PM
04-14-2005 5:31 PM
Are you using a field-symbol to load the data to the grid? If you are, the changes you make in the grid will also be changed in the field-symbol. You might need to use one of the refresh methods or use check_changed_data to refresh the data into the field-symbol. I used a field-symbol, and then used check_changed_data before trying to save the data. When I did this, the field symbol always had the changed data in it.
Brian
04-14-2005 5:55 PM
hi brain,
thanks for reply.
i have not tried field-symbol to load data can you explain me more in detail if possible with example.
i have created a user_command on the alv toolbar menu as a SAVE BUTTON.
when i click this button there are some condtions which should check after a change in data on grid if they are satisfied then there must be msg showing do you want to update.
i tried this way but how to update the database table.
METHOD handle_user_command.
CASE e_ucomm.
WHEN 'SAVE'.
if ( )
else
msg 'Do you want to update'.
do you have any example for this programme.
thanks in advance.
regards,
venu.
04-14-2005 6:16 PM
The code below isn't a working program, but has most of what you should need. Field-symbol <dyn_table> will always have what is in the grid.
FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE,
<dyn_wa>.
DATA: pt_fieldcat TYPE lvc_t_fcat,
ls_fcat TYPE lvc_s_fcat,
new_table TYPE REF TO data,
new_line TYPE REF TO data.
CREATE OBJECT g_custom_container
EXPORTING container_name = g_container.
CREATE OBJECT g_grid EXPORTING i_parent = g_custom_container.
CLEAR ls_fcat.
ls_fcat-fieldname = 'MATERIAL'.
ls_fcat-datatype = 'CHAR'.
ls_fcat-intlen = 18.
ls_fcat-outputlen = 18.
ls_fcat-coltext = 'Material'.
ls_fcat-edit = 1.
APPEND ls_fcat TO pt_fieldcat.
CLEAR ls_fcat.
ls_fcat-fieldname = 'QUANTITY'.
ls_fcat-datatype = 'INT4'.
ls_fcat-intlen = 6.
ls_fcat-outputlen = 6.
ls_fcat-coltext = 'Qty'.
ls_fcat-edit = 1.
APPEND ls_fcat TO pt_fieldcat.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = pt_fieldcat
IMPORTING
ep_table = new_table.
* assign ref variable to a field symbol
ASSIGN new_table->* TO <dyn_table>.
* Create dynamic work area and assign to FS
CREATE DATA new_line LIKE LINE OF <dyn_table>.
ASSIGN new_line->* TO <dyn_wa>.
* data_itab is filled with data that you want in grid
LOOP AT data_itab INTO data_wa.
CLEAR <dyn_wa>.
ASSIGN COMPONENT 'MATERIAL' OF STRUCTURE <dyn_wa> TO <fs>.
<fs> = data_wa-material.
ASSIGN COMPONENT 'QUANTITY' OF STRUCTURE <dyn_wa> TO <fs>.
<fs> = data_wa-quantity.
APPEND <dyn_wa> TO <dyn_table>.
ENDLOOP.
CALL METHOD g_grid->set_table_for_first_display
EXPORTING
i_structure_name = '<DYN_TABLE>'
is_variant = gs_variant
i_save = 'A'
i_default = 'X'
is_layout = gs_layout
it_toolbar_excluding = gt_exclude
CHANGING
it_outtab = <dyn_table>
it_fieldcatalog = pt_fieldcat[]
it_sort = gt_sort[].