2014 Oct 27 7:13 PM
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:
-
READ TABLE gt_output ASSIGNING <fs_output> INDEX ip_sel_row-row_id.
-
IF sy-subrc = 0.
-
IF lv_sel_value = lc_vb.
-
-
REFRESH lt_style-cellstyles.
-
CLEAR ls_style.
-
ls_style-fieldname = lc_zzminbe_new.
-
ls_style-style = cl_gui_alv_grid=>mc_style_enabled.
-
INSERT ls_style INTO TABLE lt_style-cellstyles.
-
-
<fs_output>-cellstyles = lt_style-cellstyles.
-
-
*If the MRP Type changed to ND PD then close the New Reorder Pt. l for editing
-
ELSE.
-
REFRESH lt_style-cellstyles.
-
CLEAR ls_style.
-
ls_style-fieldname = lc_zzminbe_new.
-
ls_style-style = cl_gui_alv_grid=>mc_style_disabled.
-
INSERT ls_style INTO TABLE lt_style-cellstyles.
-
-
<fs_output>-cellstyles = lt_style-cellstyles.
-
-
ENDIF.
-
ENDIF.
-
-
IF lv_sel_value IS NOT INITIAL.
-
MESSAGE i013(zmm_mrp). "Entries changed to suit MRP Type
-
gr_alv_grid->refresh_table_display( ).
-
ENDIF.
2014 Oct 28 9:38 AM
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.
2014 Oct 27 8:00 PM
hi Radek,
Try:
Call CL_GUI_CFW=>FLUSH()
after refresh table display
2014 Oct 27 8:51 PM
2014 Oct 28 1:58 AM
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
2014 Oct 28 3:40 AM
Hi radek,
Did you check BCALV_EDIT_02 ? u need to modify the internal table values data_changed event.
Thanks.
2014 Oct 28 9:11 AM
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
2014 Oct 28 10:12 AM
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
2014 Oct 28 9:38 AM
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.
2014 Oct 28 10:17 AM
2014 Oct 28 9:47 AM
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:
READ TABLE gt_output ASSIGNING <fs_output> INDEX ip_sel_row-row_id.
IF sy-subrc = 0.
IF lv_sel_value = lc_vb.
REFRESH lt_style-cellstyles.
CLEAR ls_style.
ls_style-fieldname = lc_zzminbe_new.
ls_style-STYLE = cl_gui_alv_grid=>mc_style_enabled.
INSERT ls_style INTO TABLE lt_style-cellstyles.
<fs_output>-cellstyles = lt_style-cellstyles.
*If the MRP Type changed to ND PD then close the New Reorder Pt. l for editing
ELSE.
REFRESH lt_style-cellstyles.
CLEAR ls_style.
ls_style-fieldname = lc_zzminbe_new.
ls_style-STYLE = cl_gui_alv_grid=>mc_style_disabled.
INSERT ls_style INTO TABLE lt_style-cellstyles.
<fs_output>-cellstyles = lt_style-cellstyles.
ENDIF.
ENDIF.
IF lv_sel_value IS NOT INITIAL.
MESSAGE i013(zmm_mrp). "Entries changed to suit MRP Type
gr_alv_grid->refresh_table_display( ).
ENDIF.
Cheers !!!!
Thanks & Regards
Syed