Application Development and Automation 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: 
Read only

ALV Editable Cell Issue

Former Member
0 Kudos
2,964

I have created an ALV Grid using clas cl_alv_gui_grid. Some of the fields are editable and some are not

As we can see above field New Reorder Point is editable initially for type VB  and non editable for field PD.

I have also added an event handler that if the user changes the type to PD then the field becomes non editable and vice versa for VB. It works but only to some extent.

When I change the first record to PD it becomes non editable. Then when I change the second record to PD it becomes non editable but now the first record becomes editable.

So the value for CELLSTYLE changes fine, I then refresh the display and it sitll works fine but as soon as in the debugger the execution leaves the Z code and goes to the standard SAP ALV processing it initializes that value to what it was when the table was first displayed. Hence the issue when I am processing the second record the first one opens up.

Any idea what the issue may be?

My code looks as follows on event data change:

  1. READ TABLE gt_output ASSIGNING <fs_output> INDEX ip_sel_row-row_id.
  2.    IF sy-subrc = 0.
  3. IF lv_sel_value = lc_vb.
  4.       REFRESH lt_style-cellstyles.
  5.        CLEAR ls_style.
  6.        ls_style-fieldname = lc_zzminbe_new.
  7.        ls_style-style = cl_gui_alv_grid=>mc_style_enabled.
  8.        INSERT ls_style INTO TABLE lt_style-cellstyles.
  9.        <fs_output>-cellstyles = lt_style-cellstyles.
  10. *If the MRP Type changed to ND PD then close the New Reorder Pt. l for editing
  11.      ELSE.
  12.        REFRESH lt_style-cellstyles.
  13.        CLEAR ls_style.
  14.        ls_style-fieldname = lc_zzminbe_new.
  15.        ls_style-style = cl_gui_alv_grid=>mc_style_disabled.
  16.        INSERT ls_style INTO TABLE lt_style-cellstyles.
  17.        <fs_output>-cellstyles = lt_style-cellstyles.
  18.      ENDIF.
  19. ENDIF.
  20. IF lv_sel_value IS NOT INITIAL.
  21.     MESSAGE i013(zmm_mrp). "Entries changed to suit MRP Type
  22.     gr_alv_grid->refresh_table_display( ).
  23.   ENDIF.
1 ACCEPTED SOLUTION
Read only

former_member302911
Active Participant
1,720

Hi Radek,

the event DATA_CHANGED have a parameter ER_DATA_CHANGED (TYPE REF TO CL_ALV_CHANGED_DATA_PROTOCOL) with a set of methods, one of this method is MODIFY_STYLE, try to use it. Instead of DATA_CHANGED you can also try event DATA_CHANGED_FINISHED.

Regards,

Angelo.

9 REPLIES 9
Read only

Former Member
0 Kudos
1,720

hi Radek,

Try:

Call CL_GUI_CFW=>FLUSH()

after refresh table display

Read only

0 Kudos
1,720

I have already tried it but it didn't help.

Read only

0 Kudos
1,720

Hi Radek,

Did you check if the internal table with the data that is being displayed in ALV has the updated values i.e., when you do for the second entry what is the value that is being passed to the first one changed earlier.

thanks

Sri

Read only

0 Kudos
1,720

Hi radek,

             Did you check BCALV_EDIT_02 ? u need to modify the internal table values data_changed event.

Thanks.

Read only

0 Kudos
1,720

Hi Srilakshmi,

That's the issue that the style is not retained for all the changed records only for the last one. So when I process it for the second record the value for the first one is initialised to what it was set at the program execution. I can't figure out why it works this way. It retains the values in other columns apart from the CELLSTYLE.

Radek

Read only

0 Kudos
1,720

Hi Radek,

       First you register the edit event for Grid as shown below.. so for every change it triggers the User command, then u refresh the display..

In PF Status register the Event..

CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

     IMPORTING

       E_CALLBACK_PROGRAM = 'zxxx'

       E_REPID            = 'zxxx'

       E_GRID             = G_GRID.

CALL METHOD G_GRID->REGISTER_EDIT_EVENT

     EXPORTING

       I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_MODIFIED.


and in User command..

   Pass  RS_SELFIELD-REFRESH = 'X' after changing that Column Celltab.

I hope it works fine..


Regards,

Raghu

Read only

former_member302911
Active Participant
1,721

Hi Radek,

the event DATA_CHANGED have a parameter ER_DATA_CHANGED (TYPE REF TO CL_ALV_CHANGED_DATA_PROTOCOL) with a set of methods, one of this method is MODIFY_STYLE, try to use it. Instead of DATA_CHANGED you can also try event DATA_CHANGED_FINISHED.

Regards,

Angelo.

Read only

0 Kudos
1,720

That worked perfectly!! Thank you.

Read only

Former Member
0 Kudos
1,720

Hi Radek,

you are not modifying the internal table contents, thats by it's working for the selected entry.

In order to reflect the changes, modify your internal table which you are displaying in the grid.

Example:

  1. READ TABLE gt_output ASSIGNING <fs_output> INDEX ip_sel_row-row_id.

  2.    IF sy-subrc = 0.

  3. IF lv_sel_value = lc_vb.

  4.       REFRESH lt_style-cellstyles.

  5.        CLEAR ls_style.

  6.        ls_style-fieldname = lc_zzminbe_new.

  7.        ls_style-STYLE = cl_gui_alv_grid=>mc_style_enabled.

  8.        INSERT ls_style INTO TABLE lt_style-cellstyles.

  9.        <fs_output>-cellstyles = lt_style-cellstyles.

  10.         MODIFY gt_output FROM <fs_output> INDEX ip_sel_row-row_id.
  11. *If the MRP Type changed to ND PD then close the New Reorder Pt. l for editing

  12.      ELSE.

  13.        REFRESH lt_style-cellstyles.

  14.        CLEAR ls_style.

  15.        ls_style-fieldname = lc_zzminbe_new.

  16.        ls_style-STYLE = cl_gui_alv_grid=>mc_style_disabled.

  17.        INSERT ls_style INTO TABLE lt_style-cellstyles.

  18.        <fs_output>-cellstyles = lt_style-cellstyles.

  19.       
  20.        MODIFY gt_output FROM <fs_output> INDEX ip_sel_row-row_id.
  21.      ENDIF.

  22. ENDIF.

  23. IF lv_sel_value IS NOT INITIAL.

  24.     MESSAGE i013(zmm_mrp). "Entries changed to suit MRP Type

  25.     gr_alv_grid->refresh_table_display( ).

  26.   ENDIF.


    Cheers !!!!

    Thanks & Regards

    Syed