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

Delete row in ALV

nilayghosh
Active Participant
0 Likes
2,312

Hi,

I am working on an interactive ALV list. As per the requirement I have been able to remove the standard delete button through the following technique:

...

...

ls_exclude = cl_gui_alv_grid=>mc_fc_loc_delete_row.

append ls_exclude to pt_exclude.

...

It is working fine and the delete button is removed from the tool bar as required. But it is still possible to delete a row by selecting the row and pressing the 'Delete' key in the key board. Can anyone tell be how to stop this. I have already gone through various SDN postings and "An easy reference for ALV grid control.pdf" but could not find any clue.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,893

Hi Nilay,

set field NO_ROWINS of grid layout structure to 'X'.

Sri

9 REPLIES 9
Read only

Former Member
0 Likes
1,894

Hi Nilay,

set field NO_ROWINS of grid layout structure to 'X'.

Sri

Read only

0 Likes
1,893

Hi Sri,

Thank you very much for this tip. But I still have the problem as I need to have the 'Create Row' button. When NO_ROWINS is set to 'X', both the 'Create Row' and 'Delete Row' button disappear from the toolbar and I am not able to create new row.

Any solution/work around for this?

Thanks in advance

Nilay

Read only

0 Likes
1,893

Another way is:

Declare a field in your itab called CELLTAB with TYPE LVC_T_STYL.

Add this field in your layout structure, field STYLEFNAME.

GS_LAYOUT-STYLEFNAME = 'CELLTAB'.

Loop over your itab and fill the deep itab CELLTAB. Set field celltab-style to CL_GUI_ALV_GRID=>MC_STYLE_NO_DELETE_ROW.

Good luck,

Bert

With this

Read only

0 Likes
1,893

For each row in the ALV grid, I filled the deep itab CELLTAB with all the columns that I am using in the grid and set the celltab-style = CL_GUI_ALV_GRID=>MC_STYLE_NO_DELETE_ROW.

It is not working. Am I doing something wrong.

Also I used the tip given by Sri but it takes away both the 'Create' and 'Delete' button. I need the 'Create' button intact with all the functionalities. Any help?

Thanks in advance.

Read only

0 Likes
1,893

Hi Nilay,

Did you fill the layout-stylefname = 'STYLE'?

Sri

Read only

0 Likes
1,893

Yes Sri, I did try with layout-stylefname = 'STYLE' but still not working. Apart from that I have another issue:

I need to generate a number (last no + 10) in one of the column. How to do that while inserting a new row.

Any help

Nilay

Read only

0 Likes
1,893

Hi Nilay,

--->I need to generate a number (last no + 10) in one of the column. How to do that while inserting a new row.

If you are using the standard create button to insert a new row then it is not possible.

You have to exclude the standard create button and add your own button for create row to grid toolbar.

Actually this way you will be able to solve the previous issue also as now you do not require the standard create button.

Hope this helps..

Sri

Read only

0 Likes
1,893

Hi,

It should work just fine so let me expand a little more.

STEP 1:

Your datadeclaration should look something like this:

TYPES: BEGIN OF TY_OUTTAB.

INCLUDE STRUCTURE <FILL IN YOUR STRUCTURE>.

TYPES: CELLTAB TYPE LVC_T_STYL.

TYPES: END OF TY_OUTTAB.

TYPES: TT_OUTTAB TYPE TABLE OF TY_OUTTAB.

DATA: GT_OUTTAB TYPE TABLE OF TY_OUTTAB.

DATA: GS_OUTTAB TYPE TY_OUTTAB.

DATA: GS_CELLTAB TYPE LVC_S_STYL.

DATA: GT_CELLTAB TYPE LVC_T_STYL.

DATA: L_INDEX TYPE SY-TABIX.

STEP 2:

Select wat you want to select and then loop over your itab.

LOOP AT GT_OUTTAB INTO GS_OUTTAB.

L_INDEX = SY-TABIX.

REFRESH GT_CELLTAB.

CLEAR GS_CELLTAB.

GS_CELLTAB-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_NO_DELETE_ROW.

INSERT GS_CELLTAB INTO TABLE GT_CELLTAB.

INSERT LINES OF GT_CELLTAB INTO TABLE GS_OUTTAB-CELLTAB.

MODIFY GT_OUTTAB FROM GS_OUTTAB INDEX L_INDEX.

ENDLOOP.

STEP 3:

remember to fill GS_LAYOUT-SYLEFNAME = 'CELLTAB'.

Did you do all this ?

Hope it helps.

Read only

0 Likes
1,893

Hi,

For you second question you should trigger the event data_changed, then loop over mt_mod_cells and call method modify_cell.