Application Development 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: 

Disabling a row in ALV grid

nishanthbhandar
Contributor
0 Kudos

Hi All,

Is there a way by which we can disable a row in an ALV grid display.Suppose we have three rows,can we disable the second row only and keep the rest two enabled for editing.

Thanks in advance

Nishanth

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi, of course. you can

There is a way to set the cell of ALV editable or not.

By this way, you can set every cell of row 2 to be uneditable. In addition, this solution is for OO ALV

List as following:

Add a field into your outtab of ALV

like this:

TYPES: BEGIN OF TYP_TEST,

FLD_A(10) TYPE C,

FLD_B(10) TYPE C,

FLD_C(10) TYPE C,

FLD_STYL TYPE LVC_T_STYL,

END OF TYP_TEST.

Set the layout structure

V_LAYOUT-STYLEFNAME = 'FLD_STYL'.

call method, it is necessary

CALL METHOD V_GRID->SET_READY_FOR_INPUT

EXPORTING I_READY_FOR_INPUT = 1.

if we have two field in ALV, named 'FLD_B', 'FLD_C'

then do like this:

LOOP AT IT_TEST INTO FLD_TEST.

IF SY-TABIX = 2.

WA_CELLSTYLE-FIELDNAME = 'FLD_B'.

WA_CELLSTYLE-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_ENABLED.

APPEND WA_CELLSTYLE TO FLD_TEST-FLD_STYL.

WA_CELLSTYLE-FIELDNAME = 'FLD_C'.

WA_CELLSTYLE-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_ENABLED.

APPEND WA_CELLSTYLE TO FLD_TEST-FLD_STYL.

MODIFY IT_TEST FROM FLD_TEST.

ENDIF.

ENDLOOP.

At last, call like this

CALL METHOD V_GRID->SET_TABLE_FOR_FIRST_DISPLAY

EXPORTING IS_LAYOUT = V_LAYOUT

CHANGING IT_OUTTAB = IT_TEST

IT_FIELDCATALOG = IT_FIELD.

Then, in the second rows of IT_TEST, the field 'FLD_B', 'FLD_C' is editable, 'FLD_A' is uneditable

That's all steps, hope it will be helpful

1 REPLY 1

Former Member
0 Kudos

Hi, of course. you can

There is a way to set the cell of ALV editable or not.

By this way, you can set every cell of row 2 to be uneditable. In addition, this solution is for OO ALV

List as following:

Add a field into your outtab of ALV

like this:

TYPES: BEGIN OF TYP_TEST,

FLD_A(10) TYPE C,

FLD_B(10) TYPE C,

FLD_C(10) TYPE C,

FLD_STYL TYPE LVC_T_STYL,

END OF TYP_TEST.

Set the layout structure

V_LAYOUT-STYLEFNAME = 'FLD_STYL'.

call method, it is necessary

CALL METHOD V_GRID->SET_READY_FOR_INPUT

EXPORTING I_READY_FOR_INPUT = 1.

if we have two field in ALV, named 'FLD_B', 'FLD_C'

then do like this:

LOOP AT IT_TEST INTO FLD_TEST.

IF SY-TABIX = 2.

WA_CELLSTYLE-FIELDNAME = 'FLD_B'.

WA_CELLSTYLE-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_ENABLED.

APPEND WA_CELLSTYLE TO FLD_TEST-FLD_STYL.

WA_CELLSTYLE-FIELDNAME = 'FLD_C'.

WA_CELLSTYLE-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_ENABLED.

APPEND WA_CELLSTYLE TO FLD_TEST-FLD_STYL.

MODIFY IT_TEST FROM FLD_TEST.

ENDIF.

ENDLOOP.

At last, call like this

CALL METHOD V_GRID->SET_TABLE_FOR_FIRST_DISPLAY

EXPORTING IS_LAYOUT = V_LAYOUT

CHANGING IT_OUTTAB = IT_TEST

IT_FIELDCATALOG = IT_FIELD.

Then, in the second rows of IT_TEST, the field 'FLD_B', 'FLD_C' is editable, 'FLD_A' is uneditable

That's all steps, hope it will be helpful