Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

abt editable ALV column and database updating

How to check the changed rows and update database in editable ALV?

As far as I consider, if the numbers of ALV rows is large, you don't need update all the rows but changed ones.

Is there any easy way to do that?

Former Member
Former Member replied

You can copy the contents to a table and then update the ALV output table. Compare the two tables. In case of change, update to database.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = SY-REPID

IS_LAYOUT = L_LAYOUT

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

IT_FIELDCAT = IT_FIELDCAT

TABLES

T_OUTTAB = ITAB

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM

RS_SELFIELD TYPE SLIS_SELFIELD.

DATA: GD_REPID LIKE SY-REPID,

REF_GRID TYPE REF TO CL_GUI_ALV_GRID.

ITAB1[ ] = ITAB.

IF REF_GRID IS INITIAL.

   CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

      IMPORTING

              E_GRID = REF_GRID.

ENDIF.

IF NOT REF_GRID IS INITIAL.

     CALL METHOD REF_GRID->CHECK_CHANGED_DATA .

ENDIF.

LOOP AT ITAB INTO WA_ITAB.

    READ ITAB1 INTO WA_ITAB1 KEY "provide the key using the key non editable columns .

   if wa_itab1 <> wa_itab.

        perform save_to_database.

   endif.  

endloop.

RS_SELFIELD-refresh = 'X'.

ENDFORM. "USER_COMMAND

2 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question