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

我有很多问题:

1-我想阻止在某些列上拖动和拖动的可能性。
2-我希望出现不允许的标志。
3-我希望当我选择多行时,在放置位置上将焦点集中在一个以上的单元格上。

这是我的代码:

在我的课堂上:在定义中

 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


谢谢。问候,

最佳答案

我认为这是不可能的

关于drag-and-drop - ABAP在ALV GRID上拖放对象,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27765128/

10-09 13:06