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: 

Regarding ALV

former_member508729
Active Participant
0 Kudos

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.

1 ACCEPTED SOLUTION

former_member188685
Active Contributor
0 Kudos

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

10 REPLIES 10

former_member181962
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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

former_member188685
Active Contributor
0 Kudos

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

0 Kudos

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

0 Kudos
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.

0 Kudos

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

0 Kudos

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

0 Kudos

Hi

Thanks for ur reply i got my requirement.

Thanks a lot to all.

Former Member
0 Kudos

yes u can change

in the USER_COMMAND of ALV

when 'SAVE'.

modify ztable from table itab.

Former Member
0 Kudos

HI,

Just check BALV_ from SE38.

Regards

Laxmi