Вы можете использовать компонент cntr_ddid
, который представляет остальную часть элемента управления сеткой ALV:
go_table->set_table_for_first_display(
EXPORTING
is_layout = VALUE #(
s_dragdrop = VALUE #(
cntr_ddid = l_dragdrop_handle ) )
...
Полностью работающий пример (вы можете перетаскивать строки из верхней таблицы в нижнюю таблицу)., изначально пустой - верхняя таблица берет строки из таблицы SCARR
, которые вам может потребоваться заполнить, вызвав программу SAPBC_DATA_GENERATOR
-):
CLASS lcl_app DEFINITION.
PUBLIC SECTION.
METHODS main.
METHODS on_drag FOR EVENT ondrag OF cl_gui_alv_grid IMPORTING es_row_no e_dragdropobj.
METHODS on_drop FOR EVENT ondrop OF cl_gui_alv_grid.
PRIVATE SECTION.
DATA: go_split TYPE REF TO cl_gui_easy_splitter_container,
go_table1 TYPE REF TO cl_gui_alv_grid,
go_table2 TYPE REF TO cl_gui_alv_grid,
go_dragdrop1 TYPE REF TO cl_dragdrop,
go_dragdrop2 TYPE REF TO cl_dragdrop,
gt_scarr1 TYPE TABLE OF scarr,
gt_scarr2 TYPE TABLE OF scarr,
gs_scarr TYPE scarr.
ENDCLASS.
CLASS lcl_app IMPLEMENTATION.
METHOD main.
DATA: l_effect TYPE i,
l_dragdrop_handle1 TYPE i,
l_dragdrop_handle2 TYPE i.
go_split = NEW cl_gui_easy_splitter_container( parent = cl_gui_container=>screen0 ).
go_table1 = NEW cl_gui_alv_grid( i_parent = go_split->top_left_container ).
go_table2 = NEW cl_gui_alv_grid( i_parent = go_split->bottom_right_container ).
go_dragdrop1 = NEW cl_dragdrop( ).
go_dragdrop1->add(
flavor = 'DD1'
dragsrc = abap_true
droptarget = abap_false
effect = cl_dragdrop=>move ).
go_dragdrop2 = NEW cl_dragdrop( ).
go_dragdrop2->add(
flavor = 'DD1'
dragsrc = abap_false
droptarget = abap_true
effect = cl_dragdrop=>move ).
go_dragdrop1->get_handle( IMPORTING handle = l_dragdrop_handle1 ).
go_dragdrop2->get_handle( IMPORTING handle = l_dragdrop_handle2 ).
SELECT * FROM scarr INTO TABLE gt_scarr1.
go_table1->set_table_for_first_display(
EXPORTING
i_structure_name = 'SCARR'
is_layout = VALUE #(
s_dragdrop = VALUE #(
row_ddid = l_dragdrop_handle1 ) )
CHANGING
it_outtab = gt_scarr1 ).
go_table2->set_table_for_first_display(
EXPORTING
i_structure_name = 'SCARR'
is_layout = VALUE #(
s_dragdrop = VALUE #(
cntr_ddid = l_dragdrop_handle2 ) )
CHANGING
it_outtab = gt_scarr2 ).
SET HANDLER on_drag FOR go_table1.
SET HANDLER on_drop FOR go_table2.
ENDMETHOD.
METHOD on_drag.
DATA: lt_row TYPE lvc_t_roid.
FIELD-SYMBOLS:
<ls_row> TYPE lvc_s_roid.
go_table1->get_selected_rows( IMPORTING et_row_no = lt_row ).
READ TABLE gt_scarr1 INDEX lt_row[ 1 ]-row_id INTO gs_scarr.
e_dragdropobj->object = me. " dummy to trigger ON_DROP
ENDMETHOD.
METHOD on_drop.
APPEND gs_scarr TO gt_scarr2.
go_table2->refresh_table_display( is_stable = VALUE #( col = 'X' row = 'X' ) ).
ENDMETHOD.
ENDCLASS.
PARAMETERS p_dummy.
AT SELECTION-SCREEN OUTPUT.
NEW lcl_app( )->main( ).