ALAP GRID上的ABAP拖放对象

时间:2015-01-04 11:42:08

标签: drag-and-drop sap abap

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

我有很多问题:

1-我想阻止在某些列上拖动和drog的可能性。 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

感谢。的问候,

1 个答案:

答案 0 :(得分:1)

我认为这不可能