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

Set conditional ALV row editable

Former Member
0 Likes
2,769

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.

1 ACCEPTED SOLUTION
Read only

anilsonesar
Explorer
0 Likes
1,581

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.

6 REPLIES 6
Read only

Former Member
0 Likes
1,581

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 .

Read only

0 Likes
1,581

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.

Read only

0 Likes
1,581

Any ideas....

Read only

anilsonesar
Explorer
0 Likes
1,582

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.

Read only

0 Likes
1,581

Thanks Anil. I am looking for the same.

Read only

0 Likes
1,581

Please mark the reply be as answer, for quicker reference and the benefit of community.