cancel
Showing results for 
Search instead for 
Did you mean: 

ALV Editable

Former Member
0 Kudos

HI all,

i am working on ALV Editable display where i need to save the edited data.i have a pblm while saving the data.when i am changing one cell the remaining cells data is getting as blank.please help here is my code in the perform of the evernt data_changed_finished.

loop at p_et_good_cells into wa_et_good_cells.

READ TABLE it_final ASSIGNING <fs_final> INDEX wa_et_good_cells-row_id.

IF sy-subrc = 0.

CASE wa_et_good_cells-fieldname.

WHEN 'DATE25'.

<fs_final>-date25 = wa_et_good_cells-value.

PERFORM change_hrs_sd CHANGING it_final.

WHEN 'DATE26'.

<fs_final>-date26 = wa_et_good_cells-value.

WHEN 'DATE27'.

<fs_final>-date27 = wa_et_good_cells-value.

WHEN 'DATE28'.

<fs_final>-date28 = wa_et_good_cells-value.

WHEN 'DATE29'.

<fs_final>-date29 = wa_et_good_cells-value.

WHEN 'DATE30'.

<fs_final>-date30 = wa_et_good_cells-value.

WHEN 'DATE31'.

<fs_final>-date31 = wa_et_good_cells-value.

WHEN 'DATE32'.

<fs_final>-date32 = wa_et_good_cells-value.

WHEN 'DATE33'.

<fs_final>-date33 = wa_et_good_cells-value.

WHEN 'DATE34'.

<fs_final>-date34 = wa_et_good_cells-value.

WHEN 'DATE35'.

<fs_final>-date35 = wa_et_good_cells-value.

WHEN 'DATE36'.

<fs_final>-date36 = wa_et_good_cells-value.

WHEN 'DATE37'.

<fs_final>-date37 = wa_et_good_cells-value.

WHEN 'DATE38'.

<fs_final>-date38 = wa_et_good_cells-value.

WHEN 'DATE39'.

<fs_final>-date39 = wa_et_good_cells-value.

WHEN 'DATE40'.

<fs_final>-date40 = wa_et_good_cells-value.

WHEN 'DATE41'.

<fs_final>-date41 = wa_et_good_cells-value.

WHEN 'DATE42'.

<fs_final>-date42 = wa_et_good_cells-value.

WHEN 'DATE43'.

<fs_final>-date43 = wa_et_good_cells-value.

WHEN 'DATE44'.

<fs_final>-date44 = wa_et_good_cells-value.

WHEN 'DATE45'.

<fs_final>-date45 = wa_et_good_cells-value.

WHEN 'DATE46'.

<fs_final>-date46 = wa_et_good_cells-value.

WHEN 'DATE47'.

<fs_final>-date47 = wa_et_good_cells-value.

WHEN 'DATE48'.

<fs_final>-date48 = wa_et_good_cells-value.

ENDCASE.

clear wa_et_good_cells.

unassign <fs_final>.

ENDIF.

ENDLOOP.

please help.

Accepted Solutions (0)

Answers (7)

Answers (7)

Former Member
0 Kudos

solved by self

Former Member
0 Kudos

Hi Kiran,

u can try the same thing like this:-

METHOD handle_data_changed.

error_in_data = space.

CALL METHOD perform_checks( er_data_changed ).

IF error_in_data = 'X'.

CALL METHOD er_data_changed->display_protocol.

ENDIF.

ENDMETHOD. "handle_data_changed

METHOD perform_checks.

PERFORM data_checks USING pr_data_changed

CHANGING error_in_data.

ENDMETHOD.

FORM data_checks USING

p_data_changed TYPE REF TO cl_alv_changed_data_protocol

CHANGING p_error.

DATA: ls_good TYPE lvc_s_modi.

Data: l_tabix LIKE sy-tabix.

DATA: ls_fcat LIKE LINE OF p_data_changed->mt_fieldcatalog.

FIELD-SYMBOLS: <l_fs> TYPE ANY.

LOOP AT p_data_changed->mt_mod_cells INTO ls_good.

CLEAR:l_htype.

CASE ls_good-fieldname.

WHEN 'your field name here'.

CHECK ls_good-value IS NOT INITIAL.

variable = ls_good-value.

p_error = 'X'.

IF NOT p_error = 'X'.

CALL METHOD p_data_changed->get_cell_value

EXPORTING

i_row_id = ls_good-row_id

i_fieldname = 'IField name here'

IMPORTING

e_value = l_instance.

  • Checking the ALV Grid from which the method is being called

READ TABLE p_data_changed->mt_fieldcatalog

INTO ls_fcat WITH KEY fieldname = 'field name here'.

IF sy-subrc <> 0.

Message.

  • Modifying the Main Internal Table--Level 1 and 2

*&>>

READ TABLE <dyn_table> INTO <dyn_wa> INDEX ls_good-row_id.

IF sy-subrc = 0.

ASSIGN COMPONENT ls_good-fieldname OF

STRUCTURE <dyn_wa> TO <l_fs>.

<l_fs> = ls_good-value.

MOVE-CORRESPONDING <dyn_wa> TO wa_final.

MODIFY <dyn_table> FROM <dyn_wa> INDEX ls_good-row_id

ASSIGNING <l_fs> TRANSPORTING (ls_good-fieldname).

*Code for capturing the changed data in first grid "29/9/2008

READ TABLE <dyn_table> INTO <dyn_wa> INDEX ls_good-row_id.

READ TABLE it_final WITH KEY instance = l_instance.

MOVE-CORRESPONDING it_final TO it_final_tmp.

MOVE-CORRESPONDING <dyn_wa> TO it_final_tmp.

APPEND it_final_tmp. (same as your final table)

ENDIF.

PERFORM insert_modify_table USING p_data_changed CHANGING p_error.

.

ENDFORM. " DATA_CHECKS

In form insert_modify_table u can use the function module to save data.

Thanks & Regards

Ruchi Tiwari

sujeet2918
Active Contributor
0 Kudos

Hello Kiran,

First you make your ALV editable in in output window put one pushbutton for SAVE.

Refer Below Code for your Refference.

***Declaration

data: gd_layout type slis_layout_alv,

***Values For passing Editable ALV

gd_layout-box_fieldname = 'SEL'.

"set field name to store row selection

gd_layout-edit = 'X'. " this makes ALV Editable.

gd_layout-zebra = 'X'.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = gd_repid

i_callback_top_of_page = 'TOP-OF-PAGE'

i_callback_user_command = 'USER_COMMAND'

i_grid_title = outtext

is_layout = gd_layout " Pass your layout.

it_fieldcat = fieldcatalog[]

    • it_special_groups = gd_tabgroup

    • IT_EVENTS = GT_XEVENTS

i_save = 'X'

    • is_variant = z_template

*

tables

t_outtab = it_itab

  • exceptions

  • program_error = 1

  • others = 2.

  • if sy-subrc <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

  • endif.

And Second thing for saving data in database:

you can use CASE: SY-UCOMM.

WHEN 'SAVE'.

then you UPDATE the table.

it will update your database table with your current changes.

If any Problem then tell me in Details.

Regards,

Sujeet

Former Member
0 Kudos

hi ,

Please save these values in other cell in some other

varialble , and when choose one cell again re-append

these value in these field.

I think this will solve ur problem.

Regards

Prashant

Former Member
0 Kudos

hi,

refer this program

BCALV_EDIT_05 in SE38

thanks

Former Member
0 Kudos

Hi Kiran,

When is the data getting cleared exactly after changing the value or before saving it.

Regards,

Phani.

Former Member
0 Kudos

hi,

when debuggin by the time it enters to perform of the save_data_finished it is showing all the fields empty except the edited field,yes it is after pressing save button of the handle bar of ALV

Former Member
0 Kudos

Hi Kiran,

can you post the code.

Regrads,

Phani.

Former Member
0 Kudos

in the class implementation i had written like this

CLASS event IMPLEMENTATION.

METHOD hot_spot.

PERFORM double_click USING e_row_id

e_column_id

es_row_no.

ENDMETHOD. "hot_spot

METHOD data_changed.

PERFORM change_data TABLES lt_mod_cells USING er_data_changed.

in the form

LOOP AT p_er_data_changed->mt_good_cells INTO ls_mod_cells.

break abharadw.

READ TABLE it_final ASSIGNING <fs_final> INDEX ls_mod_cells-row_id.

IF sy-subrc = 0.

CASE ls_mod_cells-fieldname.

WHEN 'DATE25'.

<fs_final>-date25 = ls_mod_cells-value.

PERFORM change_hrs_sd CHANGING it_final.

WHEN 'DATE26'.

<fs_final>-date26 = ls_mod_cells-value.

WHEN 'DATE27'.

<fs_final>-date27 = ls_mod_cells-value.

WHEN 'DATE28'.

<fs_final>-date28 = ls_mod_cells-value.

WHEN 'DATE29'.

<fs_final>-date29 = ls_mod_cells-value.

WHEN 'DATE30'.

<fs_final>-date30 = ls_mod_cells-value.

WHEN 'DATE31'.

<fs_final>-date31 = ls_mod_cells-value.

WHEN 'DATE32'.

<fs_final>-date32 = ls_mod_cells-value.

WHEN 'DATE33'.

<fs_final>-date33 = ls_mod_cells-value.

WHEN 'DATE34'.

<fs_final>-date34 = ls_mod_cells-value.

WHEN 'DATE35'.

<fs_final>-date35 = ls_mod_cells-value.

WHEN 'DATE36'.

<fs_final>-date36 = ls_mod_cells-value.

WHEN 'DATE37'.

<fs_final>-date37 = ls_mod_cells-value.

WHEN 'DATE38'.

<fs_final>-date38 = ls_mod_cells-value.

WHEN 'DATE39'.

<fs_final>-date39 = ls_mod_cells-value.

WHEN 'DATE40'.

<fs_final>-date40 = ls_mod_cells-value.

WHEN 'DATE41'.

<fs_final>-date41 = ls_mod_cells-value.

WHEN 'DATE42'.

<fs_final>-date42 = ls_mod_cells-value.

WHEN 'DATE43'.

<fs_final>-date43 = ls_mod_cells-value.

WHEN 'DATE44'.

<fs_final>-date44 = ls_mod_cells-value.

WHEN 'DATE45'.

<fs_final>-date45 = ls_mod_cells-value.

WHEN 'DATE46'.

<fs_final>-date46 = ls_mod_cells-value.

WHEN 'DATE47'.

<fs_final>-date47 = ls_mod_cells-value.

WHEN 'DATE48'.

<fs_final>-date48 = ls_mod_cells-value.

ENDCASE.

ENDIF.

unassign <fs_final>.

ENDLOOP.

clear:ls_mod_cells,

p_er_data_changed.

when i edit the displayed data .out of four displayed fields if i edit 1 field all the other are bcoming empty except the edited field.

Former Member
0 Kudos

hi

what you can do is that you can have a look at the programs of which name start with BCALV_EDIT* in the package SLIS.

they will definitely help you out.

regards

Aakash Banga