Skip to Content
author's profile photo Former Member
Former Member

Undo deleting rows in Editable ALV

Hi All,

i have to check something (at event data_changed of cl_gui_alv_grid), after the user click delete row in an editable ALV. If any expression is true, then the deleted row should not be deleted, it should be undo.

Have anyone a idea to undo this deleting-function.

Best regards

Andreas

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Feb 11, 2009 at 10:10 AM

    Hi ,

    Have a look at this standard program.BCALV_EDIT_04

    May be u will get some idea.

    Thanks

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Feb 11, 2009 at 08:46 AM

    hi,

    You can overwrite the functionality of Editable ALV . You have to pass the subroutine name program name and function code to the function module or method you are calling for displaying ALV. You can also mention whether your subroutine should be executed first or the standard code should be executed first.

    Regards,

    Veeresh

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member veereshbabu ponnada

      I mean the ALV OO.

      See

      Hi All,
      
      i have to check something (at event data_changed of cl_gui_alv_grid), after the user click delete row in an editable ALV. If any expression is true, then the deleted row should not be deleted, it should be undo.

  • author's profile photo Former Member
    Former Member
    Posted on Apr 21, 2011 at 01:47 PM

    I had the same problem. Here is how I have dealt with it:

    There are two events in ALV OO - data_changed and data_changed_finished. The first one is triggered just after the data is changed, the second one, when the data is perceived.

    In the event data_changed, you have the table with deleted rows (row numbers). Loop at this table, get row numbers and read the deleted records from the table on which ALV is based, (they are still in the ALV, because the change is not done yet). Now insert them back to the alv. In the data_changed_finished event call the method REFRESH_TABLE_DISPLAY.

    CODE:

    form for data_changed:

     
      DATA  
                  gt_alv                           TYPE TABLE OF <your_alv_strucuture>
                  gv_undo                      TYPE xfeld, "THIS HAS TO BE GLOBAL VARIABLE
                  lo_protocol                  TYPE REF TO cl_alv_changed_data_protocol,
                  ls_deleted_rows        TYPE lvc_s_moce,
                  ls_alv                            TYPE <your_alv_strucuture>
    
    LOOP AT lo_protocol->mt_deleted_rows INTO ls_deleted_rows.
         READ TABLE gt_alv
           INDEX ls_deleted_rows-row_id
           INTO ls_alv.
        IF sy-subrc = 0.
            gv_undo_deletion = 'X'.
            INSERT ls_alv
              INTO gt_alv          
              INDEX ls_deleted_rows-row_id.
        ENDIF.
     

    form for data_changed_finished:

     
    IF gv_undo= 'X'.
        CLEAR gv_undo.
        CALL METHOD go_grid->refresh_table_display.
     ENDIF.
    

    Edited by: piotrzym on Apr 21, 2011 3:47 PM

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.