ABAP 在 ALV GRID 上拖放对象

ABAP drag and drop object on ALV GRID

我在我的 alv 网格上发现了拖放对象,但是当我搜索文档时很难理解流程,

我有很多问题:

  1. 我想阻止在某些列上拖拽的可能性。
  2. 并且我希望出现不允许的标志。
  3. 我希望当我 select 多行时,在放置位置显示多个单元格上的焦点。

这是我的代码:

在我的 Class 中:在定义中

 on_drag           FOR EVENT ondrag OF cl_gui_alv_grid
                    IMPORTING e_column e_row es_row_no e_dragdropobj,

  on_drop           FOR EVENT ondrop OF cl_gui_alv_grid
                    IMPORTING e_column e_row es_row_no e_dragdropobj,

实施中:

  METHOD on_drag.
    DATA: lr_objct   TYPE REF TO lcl_dragdropobj.

    CREATE OBJECT lr_objct.

    gr_alvpl->get_selected_cells( IMPORTING et_cell = lr_objct->lt_cells ).

    e_dragdropobj->object         = lr_objct.

  ENDMETHOD.                    "on_drag

  METHOD on_drop.
    DATA: lv_lines    TYPE i,
          lv_tolin    TYPE i,
          lv_icone    TYPE icon,
          ls_cells    TYPE lvc_s_cell,
          ls_colmn    TYPE lvc_s_col,
          ls_trows    TYPE lvc_s_row,
          ls_tbalv    TYPE zscad_planification,
          lv_value    TYPE string,
          lr_objct    TYPE REF TO lcl_dragdropobj.

   FIELD-SYMBOLS: <struc>  TYPE zscad_planification,
                  <value>  TYPE ANY.

    PERFORM verif_before_dad.

    lr_objct                      ?= e_dragdropobj->object.

    DESCRIBE TABLE lr_objct->lt_cells LINES lv_lines.

    lv_tolin                      = e_row + lv_lines.

*
*    DATA: lt_field TYPE TABLE OF sval,
*          ls_field TYPE sval.
*
*    ls_field-fieldname            = 'comment'.
*    ls_field-fieldtext            = 'Vous pouvez saisir un message'.
*    APPEND ls_field TO lt_field.
*    CALL FUNCTION 'POPUP_GET_VALUES'
*      EXPORTING
**       NO_VALUE_CHECK        = ' '
*        popup_title           = 'Confirmation'
**       START_COLUMN          = '5'
**       START_ROW             = '5'
**     IMPORTING
**       RETURNCODE            =
*      tables
*        fields                = lt_field
**     EXCEPTIONS
**       ERROR_IN_FIELDS       = 1
**       OTHERS                = 2
*              .
*    IF sy-subrc <> 0.
** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
**         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*    ENDIF.


    LOOP AT lr_objct->lt_cells INTO ls_cells.
      CLEAR: ls_colmn, ls_trows.

      ls_colmn                    = ls_cells-col_id.
      ls_trows                    = ls_cells-row_id.

      READ TABLE gt_tbalv ASSIGNING <struc> INDEX ls_trows-index.
      IF sy-subrc EQ 0.
        CONCATENATE '<struc>-' ls_colmn-fieldname INTO lv_value.
        ASSIGN (lv_value) TO <value>.
        lv_icone                 = <value>.
        CLEAR: <value>.
      ENDIF.
    ENDLOOP.

* Fill the new Day
    LOOP AT lr_objct->lt_cells INTO ls_cells.
        CLEAR: ls_colmn, ls_trows.
        ls_colmn                    = e_column.
*        ls_colmn                    = ls_cells-col_id.
        ls_trows                    = ls_cells-row_id.

        READ TABLE gt_tbalv ASSIGNING <struc> INDEX ls_trows-index.
        IF sy-subrc EQ 0.
         CONCATENATE '<struc>-' ls_colmn-fieldname INTO lv_value.
         ASSIGN (lv_value) TO <value>.
         <value> = lv_icone.
        ENDIF.
    ENDLOOP.


    gr_alvpl->refresh_table_display( ).

  ENDMETHOD.                    "on_drop

  METHOD on_date_selected.
    gv_datax                      = date_begin.
    PERFORM destroy_all_object.
*    PERFORM refresh_alv.

  ENDMETHOD.

当我构建我的 ALV 时,我启动了这个例程:

FORM alv_dragdrop.
  DATA: lv_effct    TYPE i,
        lv_hndla    TYPE i,
        ls_dragd    TYPE lvc_s_dd01.

* Define a behaviour for drag and drop on ALV objects and get its handle.

* Define a drag & Drop behaviour for the whole grid
  CREATE OBJECT gr_dragd.

  lv_effct                        = cl_dragdrop=>move + cl_dragdrop=>copy.

  CALL METHOD gr_dragd->add
    EXPORTING
      flavor                      = 'Line'
      dragsrc                     = 'X'
      droptarget                  = 'X'
      effect                      = lv_effct.

  CALL METHOD gr_dragd->get_handle
    IMPORTING
      handle                    = lv_hndla.

* Provide handle to alv control using the layout-structure
  ls_dragd-row_ddid               = lv_hndla.
  gs_layou-s_dragdrop             = ls_dragd.
ENDFORM.                    " ALV_DRAGDROP

谢谢。此致,

我觉得不可能