SAP resource site

ALV grid is normally used to display the report/program output. But there are cases where you need edit functionality in ALV grid.

Having a editable column/ field is very simple in ALV grid. During field catalog population just set the edi property of the column.

I.e,

wa_fieldcat-edit = 'X'.

Now , Not so easy task is to code the logic to save the data after edit operation.

We have to use events for the same.i_callback_user_command = gt_callback_subroutineis used to activate a subroutine 'USER_COMMAND' which will be triggered on each user action on ALV (Mouse click , Button click etc).We need to code in this subroutine.

SAVE button is having a function code '&DATA_SAVE'. So we need to check if sy-ucom = '&DATA_SAVE'.

Whenever any edit is done in ALV grid , the same is reflected back in the internal table used. So we can use the latest contents of internal table to update/ do our operations. To get only those fields which are modified , better to copy the internal table to some temp table and compare each row with the new contents.