‎2011 Jan 18 7:06 AM
Hi all,
I am displaying an ALv in module pool. This ALV have some as display mode and some fields in Editable mode. I have a button an ALV toolbar to insert a new ALV row.
My issue is when I Insert a new entry in this ALV row, I want all the column of that patricular row comes in editable mode.
Please suggest.
‎2011 Jan 18 7:56 AM
Suppose you are using gt_itab in ALV.
Now this Table should of Type one Database Table or Structure...
Insert "t_style" as a column in that table or Structure
t_style should be of type "LVC_T_STYL"
Now you have one more Column in your table.
This Column will be used in Setting Layout of Every row Which should be in Edit mode and which should not be.
it all depends on value Present in Field.
now see the following Subroutine
Suppose Database Table and Structure zs_itab contains following Columns :
COL1
COL2
COL3
t_style
FORM edit_mode_determine CHANGING lwa_itab TYPE zs_itab.
DATA : lwa_style TYPE lvc_s_styl.
REFRESH lwa_itab-t_style.
CLEAR lwa_style.
IF lwa_itab-COL1 IS INITIAL
lwa_style-fieldname = 'COL1'.
lwa_style-style = cl_gui_alv_grid=>mc_style_enabled. "Enabled will enable cell to be Editable
INSERT lwa_style INTO TABLE lwa_itab-t_style.
ELSE.
lwa_style-fieldname = 'COL1'.
lwa_style-style = cl_gui_alv_grid=>mc_style_disabled. "Disabled will make cell to be not Editable
INSERT lwa_style INTO TABLE lwa_itab-t_style.
ENDIF.
IF lwa_itab-COL2 IS INITIAL
lwa_style-fieldname = 'COL2'.
lwa_style-style = cl_gui_alv_grid=>mc_style_enabled. "Enabled will enable cell to be Editable
INSERT lwa_style INTO TABLE lwa_itab-t_style.
ELSE.
lwa_style-fieldname = 'COL2'.
lwa_style-style = cl_gui_alv_grid=>mc_style_disabled. "Disabled will make cell to be not Editable
INSERT lwa_style INTO TABLE lwa_itab-t_style.
ENDIF.
IF lwa_itab-COL3 IS INITIAL
lwa_style-fieldname = 'COL3'.
lwa_style-style = cl_gui_alv_grid=>mc_style_enabled. "Enabled will enable cell to be Editable
INSERT lwa_style INTO TABLE lwa_itab-t_style.
ELSE.
lwa_style-fieldname = 'COL3'.
lwa_style-style = cl_gui_alv_grid=>mc_style_disabled. "Disabled will make cell to be not Editable
INSERT lwa_style INTO TABLE lwa_itab-t_style.
ENDIF.
ENDFORM.
By above Code you will be able to set whether row is Editable or not
and you need to Specify this "t_style" in ls_layout which is passed in Field_catalog_prepare
ls_layout-stylefname = 'T_STYLE'.
only after exporting this layout variable you will be able to see Changes in ALV Grid.
‎2011 Jan 18 7:15 AM
Hi Sanket when inserting new row you must be regenarating the alv again using a new field catalog right . Can you put edit = x when insterting the new field in the field catalog .
‎2011 Jan 18 7:23 AM
Hi Debojyoti,
Actually I don't want to change whole table column as editable. I just want to change the column of the particular row as editable which I recently inserted.
‎2011 Jan 18 7:50 AM
‎2011 Jan 18 7:56 AM
Suppose you are using gt_itab in ALV.
Now this Table should of Type one Database Table or Structure...
Insert "t_style" as a column in that table or Structure
t_style should be of type "LVC_T_STYL"
Now you have one more Column in your table.
This Column will be used in Setting Layout of Every row Which should be in Edit mode and which should not be.
it all depends on value Present in Field.
now see the following Subroutine
Suppose Database Table and Structure zs_itab contains following Columns :
COL1
COL2
COL3
t_style
FORM edit_mode_determine CHANGING lwa_itab TYPE zs_itab.
DATA : lwa_style TYPE lvc_s_styl.
REFRESH lwa_itab-t_style.
CLEAR lwa_style.
IF lwa_itab-COL1 IS INITIAL
lwa_style-fieldname = 'COL1'.
lwa_style-style = cl_gui_alv_grid=>mc_style_enabled. "Enabled will enable cell to be Editable
INSERT lwa_style INTO TABLE lwa_itab-t_style.
ELSE.
lwa_style-fieldname = 'COL1'.
lwa_style-style = cl_gui_alv_grid=>mc_style_disabled. "Disabled will make cell to be not Editable
INSERT lwa_style INTO TABLE lwa_itab-t_style.
ENDIF.
IF lwa_itab-COL2 IS INITIAL
lwa_style-fieldname = 'COL2'.
lwa_style-style = cl_gui_alv_grid=>mc_style_enabled. "Enabled will enable cell to be Editable
INSERT lwa_style INTO TABLE lwa_itab-t_style.
ELSE.
lwa_style-fieldname = 'COL2'.
lwa_style-style = cl_gui_alv_grid=>mc_style_disabled. "Disabled will make cell to be not Editable
INSERT lwa_style INTO TABLE lwa_itab-t_style.
ENDIF.
IF lwa_itab-COL3 IS INITIAL
lwa_style-fieldname = 'COL3'.
lwa_style-style = cl_gui_alv_grid=>mc_style_enabled. "Enabled will enable cell to be Editable
INSERT lwa_style INTO TABLE lwa_itab-t_style.
ELSE.
lwa_style-fieldname = 'COL3'.
lwa_style-style = cl_gui_alv_grid=>mc_style_disabled. "Disabled will make cell to be not Editable
INSERT lwa_style INTO TABLE lwa_itab-t_style.
ENDIF.
ENDFORM.
By above Code you will be able to set whether row is Editable or not
and you need to Specify this "t_style" in ls_layout which is passed in Field_catalog_prepare
ls_layout-stylefname = 'T_STYLE'.
only after exporting this layout variable you will be able to see Changes in ALV Grid.
‎2011 Jan 18 9:55 AM
‎2015 Jul 08 1:16 PM