05-24-2006 12:11 PM
Hi all,
I am using alv grid display where i had put only one column as editable. now what i need is,can we change the data in database at one go although i changes more than one records.
e.g. I got 8 records in alv and i changed values of ok status for all 8 records
can we change all 8 record's new values in database at one go.
05-24-2006 12:20 PM
yes, it is possible.
only thing is you need to capture the changed records, and then you need to use modify.
collect all changed records to IT_CHANGE then use
<b>MODIFY ZTABLE FROM IT_CHANGE.</b>
Regards
vijay
05-24-2006 12:13 PM
Capture the changed values n the alv into an iinternal tabel.
Use the statement in the user_command routine.
modify ztable from table itab.
This way, the changes are updated to the database at one go.
See the sample program:
BCALV_TEST_GRID_EDITABLE
Regards,
Ravi
05-24-2006 12:14 PM
Yes you can. Get all the changes into the internal table and use the MODIFY statement.
MODIFY dbtab FROM ITAB.
Regards,
Ravi
NOte : Please mark all the helpful answers
05-24-2006 12:20 PM
yes, it is possible.
only thing is you need to capture the changed records, and then you need to use modify.
collect all changed records to IT_CHANGE then use
<b>MODIFY ZTABLE FROM IT_CHANGE.</b>
Regards
vijay
05-24-2006 12:31 PM
Thanks for ur valuable reply,.
But problem here is that we can capture the changed values only after any user command event. and here i am using slis_selfield for getting current index and value. so it only picks up last changed record and no others.
Can u just help me how to pick up all the changed records in internal table for that alv display.
Thanks
05-24-2006 12:35 PM
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = W_REPID
I_CALLBACK_PF_STATUS_SET = 'PF_STATUS'
<b>I_CALLBACK_USER_COMMAND = 'USER_COMMAND'</b>
FORM USER_COMMAND USING P_UCOMM TYPE SY-UCOMM
P_SELFLD TYPE SLIS_SELFIELD.
case p_ucomm.
when 'SAVE'.
<b> Data ref1 type ref to cl_gui_alv_grid.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = ref1.
call method ref1->check_changed_data</b>
modift ztable from table itab.
endcase.
ENDFORM.
05-24-2006 12:41 PM
If you are using ALV GRID then you need to use Chandra sekhar's logic also.
if you want to capture only Changed record then ...
you should take the Backup before display, now you will change the contents in ALV. so in user_command action SAVE you have to code some thing like this...
LOOP AT IT_BACKUP.
read table it_changed index sy-tabix.
if sy-subrc = 0.
if it_backup <> it_changed.
move corresponding it_changed to it_save.
append it_save.
clear it_save.
endif.
endif.
ENDLOOP.
also try to put the code mentioned By Mr Chandrasekhar. to reflect the changes to internal table IT_CHNAGE if you use ALV GRID FM
Regards
vijay
05-24-2006 12:43 PM
Hi,
now you have changed data in <b>it_save</b> , so you can use that and modify the table,
Modify ZTABLE from IT_SAVE.
Regards
vijay
05-24-2006 12:55 PM
05-24-2006 12:31 PM
yes u can change
in the USER_COMMAND of ALV
when 'SAVE'.
modify ztable from table itab.
05-24-2006 12:37 PM