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: 

Add new editable row to ALV grid

buddhika_krishantha
Active Participant

Hi,

I have created a ALV grid using the class CL_GUI_ALV_GRID and it has a editable column. Now I want to add a new row once the "Add Row" button clicked and in that row all the columns should be editable. Is there any possibility to do that?

9 REPLIES 9

omer_sakar
Participant

Hi,

There is a standard report: BCALV_EDIT_02 . It can help you.

buddhika_krishantha
Active Participant

Rows are not editable once I Insert a Row.

0 Kudos

I think you need to write some code to make row editable after insert. check the logic to make column editable when ALV initial.

0 Kudos

Please use the COMMENT button for comments, questions, adding details, etc., ANSWER is only to propose a solution, dixit SAP text at the right of the answer area.

SimoneMilesi
Active Contributor
0 Kudos

Are you using cell style?

0 Kudos

can u please give the code for adding a row in alv output

raymond_giuseppi
Active Contributor

Use of CL_GUI_ALV_GRID=>MC_STYLE_ENABLED on every cell of the added row, or at least on every required field.

Or once by defining FIELDNAME = space.

PS: the ALV table must contain a column of type LVC_T_STYL, its value must be set for the added row with values for FIELDNAME and STYLE, the method SET_TABLE_FOR_FIRST_DISPLAY must be called with structured parameter IS_LAYOUT having component STYLEFNAME = name of the column of type LVC_T_STYL.

Sandra_Rossi
Active Contributor

The rows added with the standard NEW button will take the editable mode (enabled or disabled) of the edit mode of the whole ALV Grid (component EDIT of parameter IS_LAYOUT of method SET_TABLE_FOR_FIRST_DISPLAY).

So the solution is:

  • make the ALV grid editable by default (IS_LAYOUT = VALUE #( EDIT = 'X' )) - The new rows will inherit that edit mode.
  • eventually, make all the existing rows NOT editable by default (ALV style "disabled" for all cells i.e. FIELDNAME = space) (row style has priority over ALV Grid style)
  • eventually, if you have made some rows NOT editable, make the cells editable via ALV style again (cell style has priority over row style).

NB: to use ALV styles, the ALV table must contain a column of type LVC_T_STYL, its value must be set for the added row with values for FIELDNAME and STYLE, the method SET_TABLE_FOR_FIRST_DISPLAY must be called with structured parameter IS_LAYOUT having component STYLEFNAME = name of the column of type LVC_T_STYL.