Search code examples
abapalv

SAP ABAP Append alv row to an other table dynamically?


This is the picture

How can I get the selection of the row event?

if (alv_table_1_row) is selected or if button is pressed 
append to alv_table_2

Can somebody help me? I want at the click of the row to be appended into alv_table_2 dynamically?


Solution

  • Create a local class like below to handle double-click row event of ALV grid.

    class lcl_alv_event_receiver definition.
    
      public section.
    
      methods:  handle_double_click.
        for event double_click of cl_gui_alv_grid
            importing e_row e_column.
    
    endclass.  
    
    class lcl_alv_event_receiver implementation.
    
        method handle_double_click.
            " Your event handler code here like below
            " read table alv_table_1 index e_row-index into ls_row.
            " append ls_row to alv_table_2.
            " alv_table_2_grid->refresh_table_display( ).
        endmethod.
    
    endclass.
    

    Register your event handler somewhere in your code after your left ALV is initialized.

     data:  lo_alv_event_receiver  type ref to lcl_event_receiver.
        create object lo_alv_event_receiver.
    
        set handler lo_alv_event_receiver->handle_double_click for alv_table_1_grid.